Skip to content

Add headers to CORS middleware#186

Merged
zhouzhuojie merged 1 commit into
masterfrom
zz/add-headers-to-cors
Oct 30, 2018
Merged

Add headers to CORS middleware#186
zhouzhuojie merged 1 commit into
masterfrom
zz/add-headers-to-cors

Conversation

@zhouzhuojie
Copy link
Copy Markdown
Collaborator

No description provided.

@zhouzhuojie zhouzhuojie requested a review from mjramosb October 30, 2018 18:10
Copy link
Copy Markdown

@mjramosb mjramosb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@zhouzhuojie zhouzhuojie merged commit 3b83965 into master Oct 30, 2018
@zhouzhuojie zhouzhuojie deleted the zz/add-headers-to-cors branch October 30, 2018 18:25
@jaysonsantos
Copy link
Copy Markdown
Contributor

Hey there, first thanks for the PR and the project
Second, it seems that this had no effect on CORS.
To reproduce it you can follow this:

make build run
# and then make an options call
curl -vXOPTIONS http://127.0.0.1:18000/api/v1/evaluation

and the output will be:

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 18000 (#0)
> OPTIONS /api/v1/evaluation HTTP/1.1
> Host: 127.0.0.1:18000
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 405 Method Not Allowed
< Allow: POST
< Content-Type: application/json
< Date: Mon, 20 Jan 2020 13:19:45 GMT
< Content-Length: 70
<
* Connection #0 to host 127.0.0.1 left intact
{"code":405,"message":"method OPTIONS is not allowed, but [POST] are"}* Closing connection 0

it seems that go-openapi's handler runs before negroni handlers and as on the spec there is no options method defined, it just cancel the request with 405.
What is the best approach to fix this? If you lead me I can try and send a PR for this.

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

Successfully merging this pull request may close these issues.

3 participants