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

Apply cross-origin headers to all incoming requests. #375

Closed
wants to merge 17 commits into from

Conversation

phyllisstein
Copy link
Contributor

Does this resolve an issue?

Fix/Close #363

Description of changes proposed in this pull request

Creates a global cross-origin middleware that applies spec-compliant CORS headers to all incoming requests.

Who should review this pull request?

@jimlambie, @adamkdean

Testing

Integration tests are passing---there's no way I can think of to do any meaningful acceptance testing, but I have confidence that this is a valid tack.

@phyllisstein phyllisstein changed the title Cors Apply cross-origin headers to all incoming requests. Dec 11, 2017
@jimlambie
Copy link
Contributor

@phyllisstein this looks great - we'll review/merge/release tomorrow morning. The inclusion of tests much appreciated!

@jimlambie
Copy link
Contributor

@eduardoboucas we'll need to port this to the 2.2.x branch, I believe

Copy link
Contributor

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

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

This looks really good, thank you @phyllisstein! I've added just a tiny detail/question.

(Thanks for adhering to all the coding styles and conventions 🙏 )

return next()
}

const method = req.method && req.method.toUpperCase && req.method.toUpperCase()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to check for the existence of both req.method and req.method.toUpperCase before using it? Would req.method ever be anything other than a string?

Copy link
Contributor

Choose a reason for hiding this comment

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

also, we lowercase it everywhere else ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😃Fair enough! Just pushed a less conservative check.

@adamkdean adamkdean self-requested a review December 12, 2017 10:06
Copy link
Contributor

@adamkdean adamkdean left a comment

Choose a reason for hiding this comment

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

Fantastic work. LGTM

@phyllisstein
Copy link
Contributor Author

Thanks for the feedback! Should I change the base branch to 2.2.x and see if Git can manage that, rather than porting it by hand?

@jimlambie
Copy link
Contributor

@phyllisstein yes please, that would be much appreciated!

@jimlambie jimlambie changed the base branch from develop to 2.2.x December 12, 2017 13:13
@jimlambie jimlambie changed the base branch from 2.2.x to develop December 12, 2017 13:29
@jimlambie
Copy link
Contributor

I've made a mess of this. Closing this PR - @phyllisstein please reopen against develop, I'm doing a new one against 2.2.x

thanks!

@jimlambie jimlambie closed this Dec 12, 2017
@phyllisstein
Copy link
Contributor Author

Done: #376! Sorry for the not-so-hot suggestion about swapping branches, that never seems to work the way I expect.

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.

Allow OPTIONS method against token & collection routes
4 participants