Communication between different websites through rest

1

I have a question, suppose you have a domain

www.example.com

and 2 subdomains

www.sub1.example.com
www.sub2.example.com

I clarify that the 3 pages use mongo express and the whole node stack.

If you would like to communicate and share information between these 3 pages, each running on your own server, what would be the way to do it through rest?

For example www.example.com they have their own configuration of users categories, etc, etc

Suppose the user model has the following structure

User={
name:{type:string,required:true},
lastName:{type:string,require:true}
....
....
sub1id:{type:Schema.Types.ObjectId,required=true},
sub2id:{type:Schema.Types.ObjectId,required=true}
...
}

Sub1id and sub2id are the user accounts in subdomain1 and 2, so let's suppose that I am in subdomain 1 and I want to bring information from the main domain to say the last 10 post of the userx, so I send a query to the api with a token that contains in it the id of the user and its session, then valid in the main domain and return the corresponding result if it has passed correctly.

The same for subdomain1 to 2 or subdomain2 to 1, etc, etc.

I wanted to know if this would be an acceptable way in terms of security and scalability or how else it could be done.

PS: It's obvious that I have to use https.

    
asked by Kevin AB 23.03.2017 в 19:35
source

0 answers