Skip to content

Commit c1ab2b3

Browse files
committed
Merge branch 'master' into develop
2 parents dbd2408 + aff3a2d commit c1ab2b3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: .env.example

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ API_URL=/editor
22
AWS_ACCESS_KEY=<your-aws-access-key>
33
AWS_REGION=<your-aws-region>
44
AWS_SECRET_KEY=<your-aws-secret-key>
5+
CORS_ALLOW_LOCALHOST=true
56
EMAIL_SENDER=<transactional-email-sender>
67
EMAIL_VERIFY_SECRET_TOKEN=whatever_you_want_this_to_be_it_only_matters_for_production
78
EXAMPLE_USER_EMAIL=[email protected]

Diff for: server/server.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,20 @@ if (process.env.BASIC_USERNAME && process.env.BASIC_PASSWORD) {
4646
}));
4747
}
4848

49-
const corsOriginsWhitelist = [
49+
const allowedCorsOrigins = [
5050
/p5js\.org$/,
5151
];
5252

53+
// to allow client-only development
54+
if (process.env.CORS_ALLOW_LOCALHOST === 'true') {
55+
allowedCorsOrigins.push(/localhost/);
56+
}
57+
5358
// Run Webpack dev server in development mode
5459
if (process.env.NODE_ENV === 'development') {
5560
const compiler = webpack(config);
5661
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }));
5762
app.use(webpackHotMiddleware(compiler));
58-
59-
corsOriginsWhitelist.push(/localhost/);
6063
}
6164

6265
const mongoConnectionString = process.env.MONGO_URL;
@@ -65,7 +68,7 @@ app.set('trust proxy', true);
6568
// Enable Cross-Origin Resource Sharing (CORS) for all origins
6669
const corsMiddleware = cors({
6770
credentials: true,
68-
origin: corsOriginsWhitelist,
71+
origin: allowedCorsOrigins,
6972
});
7073
app.use(corsMiddleware);
7174
// Enable pre-flight OPTIONS route for all end-points

0 commit comments

Comments
 (0)