Skip to content

Commit

Permalink
fix: add referer on redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Apr 27, 2022
1 parent 8e9f414 commit 0f7d447
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/edge-gateway/src/ipfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,14 @@ export async function ipfsGet(request, env) {
`https://${nCid}.${env.IPFS_GATEWAY_HOSTNAME}${redirectPath}${redirectQueryString}`
)

return Response.redirect(url, 302)
const headers = new Headers(request.headers)
headers.set('Referrer-Policy', 'unsafe-url')
headers.set('Location', url.toString())
headers.set('Referer', request.headers.get('Referer'))

return new Response(undefined, {
status: 302,
statusText: 'Found',
headers,
})
}

0 comments on commit 0f7d447

Please sign in to comment.