File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ API_URL=/editor
2
2
AWS_ACCESS_KEY = <your-aws-access-key>
3
3
AWS_REGION = <your-aws-region>
4
4
AWS_SECRET_KEY = <your-aws-secret-key>
5
+ CORS_ALLOW_LOCALHOST = true
5
6
EMAIL_SENDER = <transactional-email-sender>
6
7
EMAIL_VERIFY_SECRET_TOKEN = whatever_you_want_this_to_be_it_only_matters_for_production
7
8
EXAMPLE_USER_EMAIL = [email protected]
Original file line number Diff line number Diff line change @@ -46,17 +46,20 @@ if (process.env.BASIC_USERNAME && process.env.BASIC_PASSWORD) {
46
46
} ) ) ;
47
47
}
48
48
49
- const corsOriginsWhitelist = [
49
+ const allowedCorsOrigins = [
50
50
/ p 5 j s \. o r g $ / ,
51
51
] ;
52
52
53
+ // to allow client-only development
54
+ if ( process . env . CORS_ALLOW_LOCALHOST === 'true' ) {
55
+ allowedCorsOrigins . push ( / l o c a l h o s t / ) ;
56
+ }
57
+
53
58
// Run Webpack dev server in development mode
54
59
if ( process . env . NODE_ENV === 'development' ) {
55
60
const compiler = webpack ( config ) ;
56
61
app . use ( webpackDevMiddleware ( compiler , { noInfo : true , publicPath : config . output . publicPath } ) ) ;
57
62
app . use ( webpackHotMiddleware ( compiler ) ) ;
58
-
59
- corsOriginsWhitelist . push ( / l o c a l h o s t / ) ;
60
63
}
61
64
62
65
const mongoConnectionString = process . env . MONGO_URL ;
@@ -65,7 +68,7 @@ app.set('trust proxy', true);
65
68
// Enable Cross-Origin Resource Sharing (CORS) for all origins
66
69
const corsMiddleware = cors ( {
67
70
credentials : true ,
68
- origin : corsOriginsWhitelist ,
71
+ origin : allowedCorsOrigins ,
69
72
} ) ;
70
73
app . use ( corsMiddleware ) ;
71
74
// Enable pre-flight OPTIONS route for all end-points
You can’t perform that action at this time.
0 commit comments