2018-12-03 16:05:24 +02:00
|
|
|
Meteor.startup(() => {
|
2019-06-28 12:52:09 -05:00
|
|
|
if (process.env.CORS) {
|
2018-12-03 16:05:24 +02:00
|
|
|
// Listen to incoming HTTP requests, can only be used on the server
|
|
|
|
WebApp.rawConnectHandlers.use(function(req, res, next) {
|
|
|
|
res.setHeader('Access-Control-Allow-Origin', process.env.CORS);
|
|
|
|
return next();
|
|
|
|
});
|
|
|
|
}
|
2019-06-28 12:52:09 -05:00
|
|
|
if (process.env.CORS_ALLOW_HEADERS) {
|
2019-05-24 12:39:54 -04:00
|
|
|
WebApp.rawConnectHandlers.use(function(req, res, next) {
|
2019-06-28 12:52:09 -05:00
|
|
|
res.setHeader(
|
|
|
|
'Access-Control-Allow-Headers',
|
|
|
|
process.env.CORS_ALLOW_HEADERS,
|
|
|
|
);
|
2019-05-24 12:39:54 -04:00
|
|
|
return next();
|
|
|
|
});
|
|
|
|
}
|
2019-06-28 12:52:09 -05:00
|
|
|
if (process.env.CORS_EXPOSE_HEADERS) {
|
2019-05-24 12:39:54 -04:00
|
|
|
WebApp.rawConnectHandlers.use(function(req, res, next) {
|
2019-06-28 12:52:09 -05:00
|
|
|
res.setHeader(
|
|
|
|
'Access-Control-Expose-Headers',
|
|
|
|
process.env.CORS_EXPOSE_HEADERS,
|
|
|
|
);
|
2019-05-24 12:39:54 -04:00
|
|
|
return next();
|
|
|
|
});
|
|
|
|
}
|
2018-12-03 16:05:24 +02:00
|
|
|
});
|