Always allow localhost CORS requests
This commit is contained in:
parent
33db5fb1ef
commit
edc0e6ffb3
1 changed files with 3 additions and 4 deletions
|
@ -46,8 +46,9 @@ if (process.env.BASIC_USERNAME && process.env.BASIC_PASSWORD) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const corsOriginsWhitelist = [
|
const allowedCorsOrigins = [
|
||||||
/p5js\.org$/,
|
/p5js\.org$/,
|
||||||
|
/localhost/ // to allow client-only development
|
||||||
];
|
];
|
||||||
|
|
||||||
// Run Webpack dev server in development mode
|
// Run Webpack dev server in development mode
|
||||||
|
@ -55,8 +56,6 @@ if (process.env.NODE_ENV === 'development') {
|
||||||
const compiler = webpack(config);
|
const compiler = webpack(config);
|
||||||
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }));
|
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }));
|
||||||
app.use(webpackHotMiddleware(compiler));
|
app.use(webpackHotMiddleware(compiler));
|
||||||
|
|
||||||
corsOriginsWhitelist.push(/localhost/);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mongoConnectionString = process.env.MONGO_URL;
|
const mongoConnectionString = process.env.MONGO_URL;
|
||||||
|
@ -65,7 +64,7 @@ app.set('trust proxy', true);
|
||||||
// Enable Cross-Origin Resource Sharing (CORS) for all origins
|
// Enable Cross-Origin Resource Sharing (CORS) for all origins
|
||||||
const corsMiddleware = cors({
|
const corsMiddleware = cors({
|
||||||
credentials: true,
|
credentials: true,
|
||||||
origin: corsOriginsWhitelist,
|
origin: allowedCorsOrigins,
|
||||||
});
|
});
|
||||||
app.use(corsMiddleware);
|
app.use(corsMiddleware);
|
||||||
// Enable pre-flight OPTIONS route for all end-points
|
// Enable pre-flight OPTIONS route for all end-points
|
||||||
|
|
Loading…
Reference in a new issue