diff --git a/.env.example b/.env.example index 5e696e25..3a070317 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,7 @@ API_URL=/editor AWS_ACCESS_KEY= AWS_REGION= AWS_SECRET_KEY= +CORS_ALLOW_LOCALHOST=true EMAIL_SENDER= EMAIL_VERIFY_SECRET_TOKEN=whatever_you_want_this_to_be_it_only_matters_for_production EXAMPLE_USER_EMAIL=examples@p5js.org diff --git a/server/server.js b/server/server.js index ab8805f2..892ff85f 100644 --- a/server/server.js +++ b/server/server.js @@ -48,9 +48,13 @@ if (process.env.BASIC_USERNAME && process.env.BASIC_PASSWORD) { const allowedCorsOrigins = [ /p5js\.org$/, - /localhost/ // to allow client-only development ]; +// to allow client-only development +if (process.env.CORS_ALLOW_LOCALHOST === 'true') { + allowedCorsOrigins.push(/localhost/); +} + // Run Webpack dev server in development mode if (process.env.NODE_ENV === 'development') { const compiler = webpack(config);