I have a production environment and a staging environment. I am wondering if I can sandbox cookies between the environments. My setup looks like
Production
- domain.com - frontend SPA
- api.domain.com - backend Node
Staging
- staging.domain.com - frontend SPA
- api.staging.domain.com - backend Node
My staging cookies use the domain .staging.domain.com
so everything is fine there. But my production cookies use the domain .domain.com
so these cookies show up in the staging environment.
I've read one possible solution is to use a separate domain for staging like staging-domain.com but I would like to avoid this if possible. Are there any other solutions or am I missing something about how cookies work?