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

pouchdb-ajax: support storing cookies on Node.js #6814

Closed
ptitjes opened this issue Oct 29, 2017 · 1 comment
Closed

pouchdb-ajax: support storing cookies on Node.js #6814

ptitjes opened this issue Oct 29, 2017 · 1 comment

Comments

@ptitjes
Copy link
Contributor

ptitjes commented Oct 29, 2017

Issue

On Node.js, PouchDB does not hold a cookie jar for cookies received from server during authentication. It uses the request Node.js module to make HTTP requests but it does not configure it correctly to hold a cookie jar.

For cookies to be stored on Node.js, pouchdb-ajax's line

export default require('request');
should at least be

export default require('request').defaults({
  jar: true
});

Info

  • Environment: Node.js server (not on same host as CouchDB)
  • Platform: Node.js + Express
  • Adapter: Http
  • Server: Private remote CouchDB with SSL proxy, cookie authentication and properly configured CORS

Reproduce

  1. Connect from a Node.js server to a remote CouchDB with cookie authentication.
  2. Make a simple get query to see that the AuthSession cookie is not transmitted.

I don't know how I could setup a jsbin or such to demonstrate it, because I have no idea how I should mock a CouchDB. Please tell me if and how it is possible to do that.

ptitjes added a commit to ptitjes/pouchdb that referenced this issue Oct 29, 2017
On Node.js, PouchDB does not hold a cookie jar for cookies received
from server during authentication. It uses the request Node.js module
to make HTTP requests but it does not configure it correctly to hold
a cookie jar.

This PR adds the minimal required configuration for the request module.
ptitjes added a commit to ptitjes/pouchdb that referenced this issue Oct 29, 2017
On Node.js, PouchDB does not hold a cookie jar for cookies received
from server during authentication. It uses the request Node.js module
to make HTTP requests but it does not configure it correctly to hold
a cookie jar.

This adds the minimal required configuration for the request module.
ptitjes added a commit to ptitjes/pouchdb that referenced this issue Oct 30, 2017
ptitjes added a commit to ptitjes/pouchdb that referenced this issue Nov 2, 2017
ptitjes added a commit to ptitjes/pouchdb that referenced this issue Nov 13, 2017
On Node.js, PouchDB does not hold a cookie jar for cookies received
from server during authentication. It uses the request Node.js module
to make HTTP requests but it does not configure it correctly to hold
a cookie jar.

This adds the minimal required configuration for the request module.
ptitjes added a commit to ptitjes/pouchdb that referenced this issue Nov 13, 2017
daleharvey pushed a commit that referenced this issue Nov 14, 2017
* (#6814) - Add support to store cookies on Node.js

On Node.js, PouchDB does not hold a cookie jar for cookies received
from server during authentication. It uses the request Node.js module
to make HTTP requests but it does not configure it correctly to hold
a cookie jar.

This adds the minimal required configuration for the request module.

* (#6814) - Add a test for support for cookies on Node.js

* (#6814) - Fix and move test for support for cookies on Node.js
@ThibaultJanBeyer
Copy link

Nice, this is a fix I was looking for for a long time now! I’ll try it out the upcoming days.
If it works, I think it could potentially also close #6683 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants