Skip to content

Commit

Permalink
🔨 fix cors issue (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Platane committed Jul 6, 2024
1 parent d35dc83 commit 876448a
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export default async (req: VercelRequest, res: VercelResponse) => {
"https://platane.github.io",
"https://platane.me",
];
const reqOrigin =
req.url && new URL(req.url, `http://${req.headers.host}`)?.origin;
const allowedOrigin = allowedOrigins.find((o) => o === reqOrigin);

const allowedOrigin = allowedOrigins.find(
(o) => o === req.headers.origin
);
if (allowedOrigin)
res.setHeader("Access-Control-Allow-Origin", allowedOrigin);
}
Expand Down

0 comments on commit 876448a

Please sign in to comment.