Skip to content

Commit 1596f7c

Browse files
committed
feat: update cors config
1 parent 3307e99 commit 1596f7c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cors/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const isDev = process.env.NODE_ENV === 'development';
2+
3+
const CORS_OPTIONS = {
4+
origin: isDev ? '*' : 'https://undefinedschool.io',
5+
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
6+
};
7+
8+
module.exports = CORS_OPTIONS;

routes/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
const express = require('express');
22
const cors = require('cors');
33
const notifyPayment = require('../api/mail');
4+
const CORS_OPTIONS = require('../cors/utils');
45

56
const router = express.Router();
67

7-
router.all('*', cors());
8+
router.use(cors(CORS_OPTIONS));
89

910
router.get('/health', (req, res) => res.sendStatus(200));
1011

0 commit comments

Comments
 (0)