Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added auto sub domain feature for cookies #311

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

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
@@ -18,7 +18,8 @@
"on-headers": "~1.0.1",
"parseurl": "~1.3.1",
"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).

@@ -27,6 +27,7 @@ var Session = require('./session/session')
, 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
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.

None yet

5 participants