Skip to content

Added auto sub domain feature for cookies#311

Open
rbjarnason wants to merge 6 commits intoexpressjs:masterfrom
rbjarnason:master
Open

Added auto sub domain feature for cookies#311
rbjarnason wants to merge 6 commits intoexpressjs:masterfrom
rbjarnason:master

Conversation

@rbjarnason
Copy link

We run one node.js server that serves multiple domains and we wanted to have the cookies shared across subdomains. The usual way to do this is to set domain: '.domain.com' in the options but this is not possible as we are serving multiple domains hence this simple addition.

@gabeio gabeio added the pr label May 12, 2016
"uid-safe": "~2.1.0",
"utils-merge": "1.0.0"
"utils-merge": "1.0.0",
"parse-domain": "^0.2.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an exact version and order this to be alphabetical (otherwise npm operations will reorganize it, creating unnecessary churn).

, Cookie = require('./session/cookie')
, Store = require('./session/store')

var parseDomain = require('parse-domain');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can, please move this up with the other requires (probably right before the parseUrl one).

@dougwilson
Copy link
Contributor

Thanks for the pull request! On top of the comments I made inline, you also need to add documentation to the README for this feature as well as add unit tests that cover all new branches in code you've created here.

paulfitz added a commit to paulfitz/session that referenced this pull request Apr 22, 2020
This adds a `getDomainFromRequest` option which allows `cookie.domain`
to be computed from the request rather than set as a constant.
As an example of when this is useful, imagine serving a single app
from `*.foo.com` and `*.bar.com`, with domain being `.foo.com` for the
`*.foo.com` domains and `.bar.com` for the `*.bar.com` domains.

This may be related to expressjs#311
@dougwilson dougwilson force-pushed the master branch 2 times, most recently from 9d2e29b to 408229e Compare January 28, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants