Skip to content

Commit c44a77e

Browse files
committed
fix: include CORS headers in JSON response for improved API compatibility
1 parent adb08ec commit c44a77e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cloudflare-worker/src/routes/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,15 +2020,15 @@ export const setupRoutes = async (router: Router, env: Env) => {
20202020
timestamp: new Date().toISOString()
20212021
}, null, 2), {
20222022
status: 200,
2023-
headers: { "Content-Type": "application/json" }
2023+
headers: { ...router.corsHeaders,"Content-Type": "application/json" }
20242024
});
20252025
} catch (error) {
20262026
return new Response(JSON.stringify({
20272027
error: String(error),
20282028
stack: error instanceof Error ? error.stack : undefined
20292029
}, null, 2), {
20302030
status: 500,
2031-
headers: { "Content-Type": "application/json" }
2031+
headers: { ...router.corsHeaders,"Content-Type": "application/json" }
20322032
});
20332033
}
20342034
}
@@ -2120,15 +2120,15 @@ export const setupRoutes = async (router: Router, env: Env) => {
21202120
timestamp: new Date().toISOString()
21212121
}, null, 2), {
21222122
status: 200,
2123-
headers: { "Content-Type": "application/json" }
2123+
headers: { ...router.corsHeaders,"Content-Type": "application/json" }
21242124
});
21252125
} catch (error) {
21262126
return new Response(JSON.stringify({
21272127
error: String(error),
21282128
stack: error instanceof Error ? error.stack : undefined
21292129
}, null, 2), {
21302130
status: 500,
2131-
headers: { "Content-Type": "application/json" }
2131+
headers: { ...router.corsHeaders,"Content-Type": "application/json" }
21322132
});
21332133
}
21342134
}
@@ -2212,15 +2212,15 @@ export const setupRoutes = async (router: Router, env: Env) => {
22122212
timestamp: new Date().toISOString()
22132213
}, null, 2), {
22142214
status: 200,
2215-
headers: { "Content-Type": "application/json" }
2215+
headers: { ...router.corsHeaders,"Content-Type": "application/json" }
22162216
});
22172217
} catch (error) {
22182218
return new Response(JSON.stringify({
22192219
error: String(error),
22202220
stack: error instanceof Error ? error.stack : undefined
22212221
}, null, 2), {
22222222
status: 500,
2223-
headers: { "Content-Type": "application/json" }
2223+
headers: { ...router.corsHeaders,"Content-Type": "application/json" }
22242224
});
22252225
}
22262226
}

0 commit comments

Comments
 (0)