feat: update allowed origins to include wildcard if env not present
This commit is contained in:
+5
-6
@@ -1,11 +1,11 @@
|
|||||||
import cors from 'cors';
|
import cors from "cors";
|
||||||
import dotenv from 'dotenv';
|
import { config } from "dotenv";
|
||||||
|
|
||||||
dotenv.config();
|
config();
|
||||||
|
|
||||||
const allowedOrigins = process.env.CORS_ALLOWED_ORIGINS
|
const allowedOrigins = process.env.CORS_ALLOWED_ORIGINS
|
||||||
? process.env.CORS_ALLOWED_ORIGINS.split(",")
|
? process.env.CORS_ALLOWED_ORIGINS.split(",")
|
||||||
: ["http://localhost:4000"];
|
: ["http://localhost:4000", "*"];
|
||||||
|
|
||||||
const corsConfig = cors({
|
const corsConfig = cors({
|
||||||
origin: function (origin, callback) {
|
origin: function (origin, callback) {
|
||||||
@@ -16,10 +16,9 @@ const corsConfig = cors({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: ["GET"],
|
methods: ["GET"],
|
||||||
|
maxAge: 600,
|
||||||
credentials: true,
|
credentials: true,
|
||||||
optionsSuccessStatus: 200,
|
optionsSuccessStatus: 200,
|
||||||
maxAge: 600,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default corsConfig;
|
export default corsConfig;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user