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

better cross domain errors #4

Closed
max-mapper opened this issue Feb 18, 2012 · 3 comments
Closed

better cross domain errors #4

max-mapper opened this issue Feb 18, 2012 · 3 comments

Comments

@max-mapper
Copy link
Contributor

Given a cross domain request:

request({url: "http://pizza.com/api"}, function(e,r,b) {
  console.log(e,r,b)
})

e and b are null

request({url: "http://pizza.com/api", json:true}, function(e,r,b) {
  console.log(e,r,b)
})

e is a JSON parse syntax error and b is null

Would it be possible to detect and return an error about the single origin policy?

@jhs
Copy link
Member

jhs commented Feb 18, 2012

I hit this bug yesterday rewriting the Iris Couch signup. You're on Chrome, right? If you check your console you should see a cross-origin error. And r.body will be "". I didn't notice what r.statusCode and others were.

I prefer to get between the programmer and the XHR object as little as possible (basically just enough to follow the request API) but in this case I'd like to make it an error. Maybe it could have a .cross_origin field so you could distinguish that error from other kinds.

Another thing I need to do is check that jQuery cors flag and see exactly impact that has to the underlying XHR object.

The final thing to to to close this bug is identify how the other browsers handle a CORS failure and at least unify that for the browser-request user.

@jhs
Copy link
Member

jhs commented Aug 19, 2012

@maxogden What is the status of this bug? May I close it, or what do you think? Thanks.

@max-mapper
Copy link
Contributor Author

just tested it, got a nice error!

cors: "rejected"
message: "CORS request rejected: http://google.com"

looks good to me

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