Skip to content

Commit

Permalink
Add configurable ACCESS_CONTROL_ALLOW_ORIGIN header for CDN
Browse files Browse the repository at this point in the history
PROD-4372
  • Loading branch information
jmgasper committed Sep 28, 2023
1 parent 03490dc commit bcb3e31
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ workflows:
branches:
only:
- PROD-4183
- PROD-4372
- changelog
# This is alternate dev env for parallel testing
- "build-test":
Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
/* CDN configuration. */
CDN: {
PUBLIC: 'https://d1aahxkjiobka8.cloudfront.net',
ACCESS_CONTROL_ALLOW_ORIGIN: '*.topcoder-dev.com',
},

/* Time in MS to wait before refreshing challenge details after register
Expand Down
1 change: 1 addition & 0 deletions config/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
},
CDN: {
PUBLIC: 'https://community-app-cdn.topcoder.com',
ACCESS_CONTROL_ALLOW_ORIGIN: '*.topcoder.com',
},
COOKIES: {
MAXAGE: 7,
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const url = path.resolve(__dirname, '../../../build');
/* Sets Access-Control-Allow-Origin header to avoid CORS error.
* TODO: Replace the wildcard value by an appropriate origin filtering. */
router.use('/public/static-assets', (req, res, next) => {
res.set('Access-Control-Allow-Origin', '*');
res.set('Access-Control-Allow-Origin', `${config.CDN.ACCESS_CONTROL_ALLOW_ORIGIN}`);
next();
}, express.static(url),

Expand Down

0 comments on commit bcb3e31

Please sign in to comment.