Skip to content

Commit 0b5180d

Browse files
committed
Configure CORS localhost origin via CORS_ALLOW_LOCALHOST env var
1 parent edc0e6f commit 0b5180d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
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

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ if (process.env.BASIC_USERNAME && process.env.BASIC_PASSWORD) {
4848

4949
const allowedCorsOrigins = [
5050
/p5js\.org$/,
51-
/localhost/ // to allow client-only development
5251
];
5352

53+
// to allow client-only development
54+
if (process.env.CORS_ALLOW_LOCALHOST === 'true') {
55+
allowedCorsOrigins.push(/localhost/);
56+
}
57+
5458
// Run Webpack dev server in development mode
5559
if (process.env.NODE_ENV === 'development') {
5660
const compiler = webpack(config);

0 commit comments

Comments
 (0)