Skip to content

Commit a7a362d

Browse files
committed
chore: remove CORS headers from responses as it is handled outside
1 parent 36d7bda commit a7a362d

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

dashboard/backend/cf-serve.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { URI } from "@adviser/cement";
2+
import { Request as CFRequest, Response as CFResponse, D1Database, Fetcher } from "@cloudflare/workers-types";
13
import { drizzle } from "drizzle-orm/d1";
2-
import { D1Database, Fetcher, Request as CFRequest, Response as CFResponse } from "@cloudflare/workers-types";
34
import { CORS, createHandler } from "./create-handler.js";
4-
import { URI } from "@adviser/cement";
55
import { resWellKnownJwks } from "./well-known-jwks.js";
66

77
export interface Env {

dashboard/backend/create-handler.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,17 @@ export function createHandler<T extends DashSqlite>(db: T, env: Record<string, s
193193
return new Response("ok", {
194194
status: 200,
195195
headers: {
196-
...CORS,
197196
"Content-Type": "application/json",
198197
},
199198
});
200199
}
201200
if (!["POST", "PUT"].includes(req.method)) {
202-
return new Response("Invalid request", { status: 404, headers: CORS });
201+
return new Response("Invalid request", { status: 404 });
203202
}
204203
const rJso = await exception2Result(async () => await req.json());
205204
if (rJso.isErr()) {
206205
logger.Error().Err(rJso.Err()).Msg("createhandler-Error");
207-
return new Response("Invalid request", { status: 404, headers: CORS });
206+
return new Response("Invalid request", { status: 404 });
208207
}
209208
const jso = rJso.Ok();
210209

@@ -277,7 +276,7 @@ export function createHandler<T extends DashSqlite>(db: T, env: Record<string, s
277276
break;
278277

279278
default:
280-
return new Response("Invalid request", { status: 400, headers: CORS });
279+
return new Response("Invalid request", { status: 400 });
281280
}
282281
try {
283282
const rRes = await res;
@@ -294,7 +293,6 @@ export function createHandler<T extends DashSqlite>(db: T, env: Record<string, s
294293
{
295294
status: 500,
296295
headers: {
297-
...CORS,
298296
"Server-Timing": `total;dur=${duration.toFixed(2)}`,
299297
},
300298
},
@@ -309,7 +307,6 @@ export function createHandler<T extends DashSqlite>(db: T, env: Record<string, s
309307
return new Response(JSON.stringify(rRes.Ok()), {
310308
status: 200,
311309
headers: {
312-
...CORS,
313310
"Content-Type": "application/json",
314311
"Server-Timing": `total;dur=${duration.toFixed(2)}`,
315312
},
@@ -326,7 +323,6 @@ export function createHandler<T extends DashSqlite>(db: T, env: Record<string, s
326323
{
327324
status: 500,
328325
headers: {
329-
...CORS,
330326
"Content-Type": "application/json",
331327
"Server-Timing": `total;dur=${duration.toFixed(2)}`,
332328
},

0 commit comments

Comments
 (0)