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

Added extra check_allowed_headers kludge for Accept request header #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

llaisdy
Copy link

@llaisdy llaisdy commented Apr 12, 2016

Chrome adds an "accept" value to the Access-Control-Request-Headers request header. This was causing termination of the request.

I've added a kludge/check for this (same as the "origin" kludge/check) to cowboy_cors:check_allowed_headers/4.

Thanks

Ivan

p.s. Thanks v much for cowboy_cors!

@@ -125,6 +125,9 @@ check_allowed_headers([<<"origin">>|Tail], Allowed, Req, State) ->
%% header underpins the entire CORS framework, its inclusion in
%% the requested headers is nonsensical.
check_allowed_headers(Tail, Allowed, Req, State);
check_allowed_headers([<<"accept">>|Tail], Allowed, Req, State) ->
%% KLUDGE: for browsers that include this header.
check_allowed_headers(Tail, Allowed, Req, State);
Copy link
Owner

@danielwhite danielwhite May 7, 2016

Choose a reason for hiding this comment

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

If I recall correctly, the prior deals with Safari always requesting the Origin header, no matter what the client does. Is there a case of any browsers doing the same for Accept header?

Perhaps a slightly less restrictive default for allowed_headers when it isn't defined would be more appropriate (e.g. Accept and Content-Type)?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry it's gone out of my mind now :) reading around at the time, it seemed that browser handling of CORS was changing rapidly. Perhaps kludges - and/or less restrictive defaults - are appropriate until/unless things settle.

@danielwhite
Copy link
Owner

Thanks for the PR, @llaisdy, I'm really sorry I didn't notice this sooner.

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.

2 participants