Skip to content

Instantly share code, notes, and snippets.

@fraserxu

fraserxu/auth.js

Last active Feb 6, 2018
Embed
What would you like to do?
Handling CORS in Meteor app
/*
* packages/reststop2/auth.js
* Add a method to handle OPTIONS request
*/
// return nothing
RESTstop.add('login', {'method': 'OPTIONS'}, function() {})
/*
* 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
You can’t perform that action at this time.