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

Enable CORS #85

Merged
merged 1 commit into from
Aug 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ module.exports = function (badgerService) {
state: 'none'
});

app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');

Choose a reason for hiding this comment

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

The only thing to consider is whether there are ever going to be additional headers that may be sent from the client. Things like Cache-Control or other browser headers that may be injected?

This is a pretty generic "catch-all" that is good for general CORS. Just be sure your client isn't attaching any unexpected headers.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good point - we should def revisit when we add a CDN.

next();
});

// Redirect example using Express (see http://expressjs.com/api.html#res.redirect)
app.get('/request-orcid-user-auth', function (request, response) {
// Prepare the context
Expand Down