Skip to content

Add withCredentials option. Fix #29#33

Merged
Raynos merged 2 commits intonaugtur:masterfrom
gsf:withCredentials-option
Jul 1, 2014
Merged

Add withCredentials option. Fix #29#33
Raynos merged 2 commits intonaugtur:masterfrom
gsf:withCredentials-option

Conversation

@gsf
Copy link
Copy Markdown
Collaborator

@gsf gsf commented Jul 1, 2014

No description provided.

Comment thread index.js Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we default it to true.

We can use if (options.withCredentials !== false) { ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh that would be bad actually. What we want is

if (options.cors && options.withCredentials !== false) {

Meaning opt into cors & opt out of withCredentials

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

See browserify/http-browserify#47, which I mentioned in #29. The spec says withCredentials should default to false, so that's what people expect. Also, the wildcard is not allowed in Access-Control-Allow-Origin when it's set to true.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The spec says withCredentials should default to false, so that's what people expect

The spec has an annoying default, xhr defaults to true because that's what you want. Also I don't think breaking back compat is a good idea. Note that it should still be optin by setting cors to true, so it DOES default to false

Also, the wildcard is not allowed in Access-Control-Allow-Origin when it's set to true.

The wildcard was always a bad idea, no production service should be using it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, I wasn't aware of the best practice there, and I imagine I'm not the only one. Maybe worth a word in the README? Do you have any good resources around this issue to point at?

In the meantime I'll change it to default to true.

Raynos added a commit that referenced this pull request Jul 1, 2014
@Raynos Raynos merged commit 58e4e30 into naugtur:master Jul 1, 2014
@Raynos
Copy link
Copy Markdown
Collaborator

Raynos commented Jul 1, 2014

Published v1.12.0

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

Successfully merging this pull request may close these issues.

2 participants