We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a870c73 commit d6f0a90Copy full SHA for d6f0a90
packages/auth-server-api/src/app.ts
@@ -11,7 +11,15 @@ const app = express();
11
app.use(express.json());
12
13
// CORS configuration
14
-const corsOrigins = env.CORS_ORIGINS.split(",").map((origin) => origin.trim());
+const corsOrigins = (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => {
15
+ const allowlist = env.CORS_ORIGINS.split(",").map((origin) => origin.trim());
16
+ if (!origin || allowlist.indexOf(origin) !== -1) {
17
+ callback(null, true);
18
+ } else {
19
+ callback(new Error("Not allowed by CORS"));
20
+ }
21
+};
22
+
23
app.use(
24
cors({
25
origin: corsOrigins,
0 commit comments