Skip to content

Commit

Permalink
fix proxy header setting
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Jan 27, 2025
1 parent c02d8b2 commit de7e4e5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ async function logProxy(request: Request): Promise<Response> {

async function pureProxy(request: Request, pathname: string): Promise<Response> {
const response = await fetch(`https://logfire-api.pydantic.dev${pathname}`, request)
if (!response.headers.has('Access-Control-Allow-Origin')) {
response.headers.set('Access-Control-Allow-Origin', allowOrigin(request))
const headers = new Headers(response.headers)
if (!headers.has('Access-Control-Allow-Origin')) {
headers.set('Access-Control-Allow-Origin', allowOrigin(request))
}
return response
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers,
})
}

const preflight = (request: Request) =>
Expand Down

0 comments on commit de7e4e5

Please sign in to comment.