What is the issue:
Hello. I'm trying to test sharing cookies between multiple subdomains on my local machine with a self hosted Supertokens instance following the guides in documentation (share-sessions-across-sub-domains and multiple-api-endpoints), but I'm not able to achieve the desired outcome.
I have an auth UI (a Vue.js app) exposed on http://localhost:3030 and an application UI (also a Vue.js app) exposed on http://localhost:3010. The application UI also supports subdomains, for example http://demo.localhost:3010. Then I have a auth API (a Nest.js app) set up for supertokens auth exposed on http://localhost:3001.
It is working as expected if I log in via the auth UI and then use the application UI on http://localhost:3010. However if I use the application UI on a subdomain, e.g. http://demo.localhost:3010 whilst already been logged in via the auth UI I am getting back doesSessionExist: access token does not exist locally from the auth API.
Also looking at the Cookies on dev console for http://demo.localhost:3010 the st-last-access-token-update cookie the domain is demo.localhost and for http://localhost:3010 the domain is localhost.
I'm wondering if my Supertoken configuration is not correct or whether it's not possible to test this on localhost without changing the /etc/hosts file and/or redirecting ports (or using a some sort of reverse-proxy setup), or I have missed something obvious?
How does my configurations look like:
Both frontend applications Supertokens init are as follows:
The config seems fine. I think the issue is that you are trying to do this on .localhost. You may want to try the method of modifying the /etc/hosts file.
What is the issue: Hello. I'm trying to test sharing cookies between multiple subdomains on my local machine with a self hosted Supertokens instance following the guides in documentation (share-sessions-across-sub-domains and multiple-api-endpoints), but I'm not able to achieve the desired outcome.
I have an
auth UI
(a Vue.js app) exposed onhttp://localhost:3030
and anapplication UI
(also a Vue.js app) exposed onhttp://localhost:3010
. Theapplication UI
also supports subdomains, for examplehttp://demo.localhost:3010
. Then I have aauth API
(a Nest.js app) set up for supertokens auth exposed onhttp://localhost:3001
.It is working as expected if I log in via the
auth UI
and then use theapplication UI
onhttp://localhost:3010
. However if I use theapplication UI
on a subdomain, e.g.http://demo.localhost:3010
whilst already been logged in via theauth UI
I am getting backdoesSessionExist: access token does not exist locally
from theauth API
.Also looking at the Cookies on dev console for
http://demo.localhost:3010
thest-last-access-token-update
cookie thedomain
isdemo.localhost
and forhttp://localhost:3010
thedomain
islocalhost
.I'm wondering if my Supertoken configuration is not correct or whether it's not possible to test this on
localhost
without changing the/etc/hosts
file and/or redirecting ports (or using a some sort of reverse-proxy setup), or I have missed something obvious?How does my configurations look like: Both frontend applications Supertokens init are as follows:
The backend
auth API
Supertokens init is as follows:Anything else useful?: Environment:
vue: 3.2.47
andsupertokens-web-js: 0.5.0
@nestjs/core: 9.0.0
andsupertokens-node: 13.5.0
registry.supertokens.io/supertokens/supertokens-postgresql:4.3
andpostgres:15-alpine
.