🔨 fix cors issue (2)
This commit is contained in:
@@ -11,9 +11,10 @@ export default async (req: VercelRequest, res: VercelResponse) => {
|
|||||||
"https://platane.github.io",
|
"https://platane.github.io",
|
||||||
"https://platane.me",
|
"https://platane.me",
|
||||||
];
|
];
|
||||||
const reqOrigin =
|
|
||||||
req.url && new URL(req.url, `http://${req.headers.host}`)?.origin;
|
const allowedOrigin = allowedOrigins.find(
|
||||||
const allowedOrigin = allowedOrigins.find((o) => o === reqOrigin);
|
(o) => o === req.headers.origin
|
||||||
|
);
|
||||||
if (allowedOrigin)
|
if (allowedOrigin)
|
||||||
res.setHeader("Access-Control-Allow-Origin", allowedOrigin);
|
res.setHeader("Access-Control-Allow-Origin", allowedOrigin);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user