File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ API_URL=/editor
22AWS_ACCESS_KEY = <your-aws-access-key> 
33AWS_REGION = <your-aws-region> 
44AWS_SECRET_KEY = <your-aws-secret-key> 
5+ CORS_ALLOW_LOCALHOST = true 
56EMAIL_SENDER = <transactional-email-sender> 
67EMAIL_VERIFY_SECRET_TOKEN = whatever_you_want_this_to_be_it_only_matters_for_production 
78EXAMPLE_USER_EMAIL = examples@p5js.org 
Original file line number Diff line number Diff 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  / p 5 j s \. o r g $ / , 
5151] ; 
5252
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+ 
5358// Run Webpack dev server in development mode 
5459if  ( 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 ( / l o c a l h o s t / ) ; 
6063} 
6164
6265const  mongoConnectionString  =  process . env . MONGO_URL ; 
@@ -65,7 +68,7 @@ app.set('trust proxy', true);
6568// Enable Cross-Origin Resource Sharing (CORS) for all origins 
6669const  corsMiddleware  =  cors ( { 
6770  credentials : true , 
68-   origin : corsOriginsWhitelist , 
71+   origin : allowedCorsOrigins , 
6972} ) ; 
7073app . use ( corsMiddleware ) ; 
7174// Enable pre-flight OPTIONS route for all end-points 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments