Skip to content

Commit

Permalink
fix(cors): fix acao header
Browse files Browse the repository at this point in the history
  • Loading branch information
aaharu committed Aug 26, 2024
1 parent 3504748 commit eddcc5c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utils/internal/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,19 @@ export function createOriginHeaders(
const { origin: originOption } = options;
const origin = event.request.headers.get("origin");

if (!origin || !originOption || originOption === "*") {
if (!originOption || originOption === "*") {
return { "access-control-allow-origin": "*" };
}

if (typeof originOption === "string") {
return { "access-control-allow-origin": originOption, vary: "origin" };
if (originOption === "null") {
return { "access-control-allow-origin": "null", vary: "origin" };
}

return isCorsOriginAllowed(origin, options)
? { "access-control-allow-origin": origin, vary: "origin" }
: {};
if (origin && isCorsOriginAllowed(origin, options)) {
return { "access-control-allow-origin": origin, vary: "origin" };
}

return {};
}

/**
Expand Down

0 comments on commit eddcc5c

Please sign in to comment.