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

204 is not okay for OPTION status code (this breaks angular2) #359

Closed
ghost opened this issue Jun 6, 2017 · 4 comments
Closed

204 is not okay for OPTION status code (this breaks angular2) #359

ghost opened this issue Jun 6, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Jun 6, 2017

Our angular2 app is not working, because the koa-router sends 204 responses for the OPTION xhr calls.

Then I quickly searched for correct status codes for OPTION calls and quickly found this answer:
https://stackoverflow.com/a/31256072

koa-router incorrectly dosn't provide the Content-length Header, which it should (and therefore send a 200. not a 204).

@fl0w
Copy link

fl0w commented Jun 17, 2017

This also messes up Safari https XHR OPTIONS requests - nothing that really breaks anything but they're never closed.

@jbielick
Copy link
Collaborator

jbielick commented Jun 17, 2017

Thanks for bringing this up. I came to the same conclusion after reading the RFCs.

v7.2.1 11f6958 includes this fix and is published to NPM.

The CORS preflight response now looks like this:

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Allow: HEAD
Allow: GET
Date: Sat, 17 Jun 2017 15:47:04 GMT
Connection: keep-alive

@timbru31
Copy link

timbru31 commented Jun 17, 2017

This is IMO a breaking change for anyone checking if the response code is 204.
(Although it's now RFC compliant)

@jbielick
Copy link
Collaborator

Preflight requests are not handled in user-land, they're executed by the browser. Are you considering a different case? Could you expand on that case?

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

3 participants