1

I have my main domain example.com.

Subdomains:- auth.example.com, app.example.com, www.example.com
Backend:- api.example.com

Case 1 - When I server my subdomain static contents from Nginx and they make their API calls to api.example.com then NestJS (which is in api.example.com) is not able to set and read cookies even if cookie domain is set to .example.com

Case 2 - When auth.example.com, app.example.com static contents is served via NestJS like in this fashion:-

server{
    listen 80;
    server_name auth.example.com;
    location / {
    proxy_pass: http://backend ip address OR upstream address;
  }
}

and NestJS serve sub-domain related static contents.

Then NestJS is able to set and read cookies both from their subdomains and .example.com (global scope)

Case 2 is like working as expected, but expert says "server static content from Nginx" which I also agree. But my case 1 is not working what to do. Please Help.

I want API calls should be managed by api.example.com which will also balance load and subdomains related static contents should be served by Nginx.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197

0 Answers0