Skip to content

Commit c02d8b2

Browse files
committedJan 27, 2025··
avoid duplicate headers
1 parent e71b18a commit c02d8b2

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed
 

‎src/index.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,10 @@ async function logProxy(request: Request): Promise<Response> {
8282

8383
async function pureProxy(request: Request, pathname: string): Promise<Response> {
8484
const response = await fetch(`https://logfire-api.pydantic.dev${pathname}`, request)
85-
// add CORS headers
86-
return new Response(response.body, {
87-
status: response.status,
88-
statusText: response.statusText,
89-
headers: {
90-
...Object.fromEntries(response.headers),
91-
'Access-Control-Allow-Origin': allowOrigin(request),
92-
},
93-
})
85+
if (!response.headers.has('Access-Control-Allow-Origin')) {
86+
response.headers.set('Access-Control-Allow-Origin', allowOrigin(request))
87+
}
88+
return response
9489
}
9590

9691
const preflight = (request: Request) =>

0 commit comments

Comments
 (0)
Please sign in to comment.