Last active
February 6, 2018 09:51
-
-
Save fraserxu/685bf6c59fe4972f052d to your computer and use it in GitHub Desktop.
Handling CORS in Meteor app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* packages/reststop2/auth.js | |
* Add a method to handle OPTIONS request | |
*/ | |
// return nothing | |
RESTstop.add('login', {'method': 'OPTIONS'}, function() {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* packages/reststop2/server.js | |
* line 142 | |
*/ | |
WebApp.connectHandlers.use(function(req, res, next) { | |
// add allow origin | |
res.setHeader('Access-Control-Allow-Origin', '*'); | |
// add headers | |
res.setHeader('Access-Control-Allow-Headers', [ | |
'Accept', | |
'Accept-Charset', | |
'Accept-Encoding', | |
'Accept-Language', | |
'Accept-Datetime', | |
'Authorization', | |
'Cache-Control', | |
'Connection', | |
'Cookie', | |
'Content-Length', | |
'Content-MD5', | |
'Content-Type', | |
'Date', | |
'User-Agent', | |
'X-Requested-With', | |
'Origin' | |
].join(', ')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment