cors.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Meteor.startup(() => {
  2. // Set Permissions-Policy header to suppress browser warnings about experimental features
  3. WebApp.rawConnectHandlers.use(function(req, res, next) {
  4. // Disable experimental advertising and privacy features that cause browser warnings
  5. res.setHeader('Permissions-Policy',
  6. 'browsing-topics=(), ' +
  7. 'run-ad-auction=(), ' +
  8. 'join-ad-interest-group=(), ' +
  9. 'private-state-token-redemption=(), ' +
  10. 'private-state-token-issuance=(), ' +
  11. 'private-aggregation=(), ' +
  12. 'attribution-reporting=()'
  13. );
  14. return next();
  15. });
  16. if (process.env.CORS) {
  17. // Listen to incoming HTTP requests, can only be used on the server
  18. WebApp.rawConnectHandlers.use(function(req, res, next) {
  19. res.setHeader('Access-Control-Allow-Origin', process.env.CORS);
  20. return next();
  21. });
  22. }
  23. if (process.env.CORS_ALLOW_HEADERS) {
  24. WebApp.rawConnectHandlers.use(function(req, res, next) {
  25. res.setHeader(
  26. 'Access-Control-Allow-Headers',
  27. process.env.CORS_ALLOW_HEADERS,
  28. );
  29. return next();
  30. });
  31. }
  32. if (process.env.CORS_EXPOSE_HEADERS) {
  33. WebApp.rawConnectHandlers.use(function(req, res, next) {
  34. res.setHeader(
  35. 'Access-Control-Expose-Headers',
  36. process.env.CORS_EXPOSE_HEADERS,
  37. );
  38. return next();
  39. });
  40. }
  41. });