Skip to content

Commit

Permalink
fix(origin): pass if origin is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
ff6347 committed Aug 25, 2023
1 parent 3c9fe48 commit 5f83e16
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/build-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export async function buildServer({
});
await fastify.register(cors, {
origin: (origin, cb) => {
if (process.env.NODE_ENV === "test") cb(null, true);
if (!origin) {
cb(null, true);
return;
}
console.info(origin);
const hostname = new URL(origin as string).hostname;
if (hostname.includes("localhost") || hostname.includes("127.0.0.1")) {
// Request from localhost will pass
Expand Down

0 comments on commit 5f83e16

Please # to comment.