I am working on a MERN app that requires dynamic subdomains for each company (e.g. companyname.localhost). To achieve this, I have added the line
DANGEROUSLY_DISABLE_HOST_CHECK=true
in my .env
file.
When a user logs in at localhost:3000, cookies are created and the user is authenticated. If the user is registered with a specific company, they should be redirected to companyname.localhost while remaining logged in. However, upon redirecting to the subdomain, all cookies that were created on localhost are lost and the user is redirected to the login page again. I expected the cookies to persist on the subdomain and enable the user to remain logged in. Can someone please assist me with this issue? Thank you.