-
-
Notifications
You must be signed in to change notification settings - Fork 354
OPTIONS request during preflight check returns 500 and causes spec failure #195
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
Comments
Thanks @alexeits. Could you please provide the full call to the Pact constructor? Are you setting the https://github.com/pact-foundation/pact-js#constructor-options |
@mefellows: yes, I am: let server = pact.createServer({ cors: true, dir: pactDir, log: 'pact.log', port: 1234 });
return server.start(); It works fine as long as the request has a body. As soon as I send a request without a body Chrome starts to get 500 in |
Thanks, will have to investigate a bit further. I was able to reproduce outside of Pact JS by running the mock service directly with
cc: @bethesque any ideas? |
I've seen this before. Just trying to remember. Is the Host header present? |
|
Yes, the host header was present. The only header that wasn't present was If there's a request body then |
It's trying to populate the header with the value of |
yes, I think we are agreeing on this. It should probably skip |
I can make that change. I just want to be sure that it's valid to send a request without Access-Control-Request-Headers. It's been ages since I've done CORS, so I can't remember. |
I'm just reading https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request It seems that |
Bookmark for self to read later: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS |
I don't think it's required unconditionally. According to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers:
In the worst case it should be acceptable to send the wildcard: |
@alexeits thanks for finding that reference. I read up on all the issues that were tracking the browser support for the wildcard, and it seems that most browsers support it now, so I've gone with the logic of returning @mefellows please update to 1.47.2 of the standalone |
Software versions
Expected behaviour
Define a DELETE interaction without a body:
Invoke the web consumer in the browser, which sends
DELETE http://localhost:1234/foo
via XHRExpect the spec to pass
Actual behaviour
The spec fails during preflight check because OPTIONS returns 500
It appears that pact-mock_service doesn't like
"Access-Control-Allow-Headers":null
(see the log snippet below)Steps to reproduce via cURL:
With
Access-Control-Allow-Headers
it succeedsWithout
Access-Control-Allow-Headers
it returns 500Relevant log files
The text was updated successfully, but these errors were encountered: