Skip to content

Commit

Permalink
Headers even if not OPTIONS i think fixes stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamint08 committed May 23, 2024
1 parent f389325 commit b987dcc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ async function handleRequest(req: Request): Promise<Response> {
parsedUrl.pathname = parsedUrl.pathname.substring(0, parsedUrl.pathname.length - 1);
}

customHeaders.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
customHeaders.set("Access-Control-Allow-Headers", "*");

// options request
if (userMethod === "options") {
for (const middleware of premiddlewares) {
Expand All @@ -150,8 +153,6 @@ async function handleRequest(req: Request): Promise<Response> {
return ServerFailure("Internal Server Error");
}
}
customHeaders.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
customHeaders.set("Access-Control-Allow-Headers", "*");
if(log){
reqMessage += ` ${chalk.bold.green("200")} ${chalk.bold.gray(`${Date.now() - start}ms`)}`;
console.log(reqMessage);
Expand Down

0 comments on commit b987dcc

Please sign in to comment.