Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Add CORS headers to gateway responses #2254

Merged
merged 6 commits into from
Jul 18, 2019
Merged

Add CORS headers to gateway responses #2254

merged 6 commits into from
Jul 18, 2019

Conversation

nick
Copy link
Contributor

@nick nick commented Jul 12, 2019

This allows JSON content served from the gateway to be consumed without a CORS error.

I just tried upgrading from 0.34 to 0.36 and found this issue... adding this extra config seemed to fix it.

@alanshaw
Copy link
Member

Any chance we can get a test for this @nick so that it doesn't happen again?

@nick
Copy link
Contributor Author

nick commented Jul 15, 2019

@alanshaw I tried adding a check for the headers in test/gateway/index.js but it seems 'access-control-origin' is not set in that context. Searching the test folder for 'cors' or 'access-control' didn't yield anything useful... do you have any pointers on where I could add an appropriate test?

@alanshaw
Copy link
Member

test/gateway looks like the right place to add it - I guess you need to add a test that sends an OPTIONS request so the server sends a response back with CORS headers?

@nick
Copy link
Contributor Author

nick commented Jul 17, 2019

Turns out CORS headers are only sent in the response if I set the 'Origin' header in the request. Have now added an appropriate test.

Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

Perfect, thanks @nick!

@alanshaw alanshaw merged commit 5156a47 into ipfs:master Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants