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

CORS requests fail with Access-Control-Allow-Origin: * #14

Closed
thatsmydoing opened this issue Mar 20, 2014 · 2 comments
Closed

CORS requests fail with Access-Control-Allow-Origin: * #14

thatsmydoing opened this issue Mar 20, 2014 · 2 comments
Labels
Type: Bug For bugs and any other unexpected breakage

Comments

@thatsmydoing
Copy link
Contributor

mithril sets withCredentials to true when making XHR requests. Chrome and Firefox disallow CORS requests with credentials if the allow origin is *.

Is there any reason it's set to true instead of being configurable?

@lhorie
Copy link
Member

lhorie commented Mar 20, 2014

Hmm, I had it set to true with authentication-walled APIs in mind (which is my main use case), but for public APIs, you're right, it's not a good default. Now that I think about it, public APIs are probably more common, so I'll consider this is a bug.

In any case, the flag is configurable via m.request's config option:

var publicAPI = function(xhr) {xhr.withCredentials = false;}

m.request({
  method: "GET",
  url: "/",
  config: publicAPI
});

@lhorie lhorie added the bug label Mar 20, 2014
@lhorie
Copy link
Member

lhorie commented Mar 20, 2014

Default value for xhr.withCredentials is changed from true to default (i.e. false) in the origin/next branch and is scheduled to be released in v0.1.1

@lhorie lhorie closed this as completed Mar 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug For bugs and any other unexpected breakage
Projects
None yet
Development

No branches or pull requests

2 participants