pact-foundation / pact-stub-server

Standalone pact stub server
MIT License
75 stars 19 forks source link

'Access-Control-Allow-Origin' header is duplicated in the latest build available via docker v0.1.0 #15

Closed uglyog closed 5 years ago

uglyog commented 5 years ago

When running the stub server v0.1.0, and querying the OPTIONS as is done by browsers using the fetch API, the returned header contains the Allow-Control-Access-Origin twice. This is an error, as indicated by this message generated by Chrome.

Failed to load http://localhost:3001/<redacted>: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin 'http://localhost:3000' is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

The response looks like this:

invalid-allow-access-control

Suggestions

Maybe dependencies were silently updated when rebuilding the pact server, as a Cargo.lock file is absent. The bug might have been introduced transitively.

How to reproduce

This is only a partial reproduction, but at least gives you the correct image to play with locally.


# assuming a pact is placed into `./pacts`
docker run -v $PWD/pacts:/pacts  -p 8081:8081 pactfoundation/pact-stub-server:v0.1.0 -p 8081 -d /pacts
``

When running a GET with the browsers `fetch` API, you will see the issue above.
uglyog commented 5 years ago

@Byron-TW FYI

uglyog commented 5 years ago

I have released 0.1.1 with this fix

ghost commented 5 years ago

Thanks a lot for the fast response! I just verified it is also working for us! By the way: I am a fellow Rustacean myself and was extremely surprised to see Rust found its way into the pact ecosystem!

This was the reason I spent some time on filing a bug report, I really want to see it succeed! Now that I am aware of the location of the source, I should be able to fix things like these myself even.

All the best, Sebastian

uglyog commented 5 years ago

Yay! Welcome.