Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expect renamed debug headers #2769

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion edge-runtime/lib/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ export const buildResponse = async ({

// Remove Netlify internal headers
const headers = new Headers(
[...request.headers.entries()].filter(([key]) => !key.startsWith('x-nf-')),
[...request.headers.entries()].filter(
([key]) => !key.startsWith('x-nf-') && !key.startsWith('debug-x-nf-'),
),
)
if (request.body && !request.bodyUsed) {
// This is not ideal, but streaming to an external URL doesn't work
Expand Down
14 changes: 7 additions & 7 deletions tests/utils/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,17 @@ export async function invokeEdgeFunction(

// Checkout the stargate headers: https://github.com/netlify/stargate/blob/dc8adfb6e91fa0a2fb00c0cba06e4e2f9e5d4e4d/proxy/deno/edge.go#L1142-L1170
headers: {
'x-nf-edge-functions': functionsToInvoke.join(','),
'x-nf-deploy-id': ctx.deployID,
'x-nf-site-info': Buffer.from(
'debug-x-nf-edge-functions': functionsToInvoke.join(','),
'debug-x-nf-deploy-id': ctx.deployID,
'debug-x-nf-site-info': Buffer.from(
JSON.stringify({ id: ctx.siteID, name: 'Test Site', url: 'https://example.com' }),
).toString('base64'),
'x-nf-blobs-info': Buffer.from(
'debug-x-nf-blobs-info': Buffer.from(
JSON.stringify({ url: `http://${ctx.blobStoreHost}`, token: BLOB_TOKEN }),
).toString('base64'),
'x-nf-passthrough': 'passthrough',
'x-nf-passthrough-host': passthroughHost,
'x-nf-passthrough-proto': 'http:',
'debug-x-nf-passthrough': 'passthrough',
'debug-x-nf-passthrough-host': passthroughHost,
'debug-x-nf-passthrough-proto': 'http:',
'x-nf-request-id': v4(),
Comment on lines +476 to 487
Copy link
Contributor

@pieh pieh Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those probably should not change as they are used to make @netlify/edge-bundler serve work. Looking at how CLI handles those:

Those should not be prefixed as they are request headers that setup edge function invocations and not response headers

Also https://github.com/netlify/edge-functions-bootstrap/blob/e49ee4a71e417c5ba91759a24f5b6ae0bd3ecc2c/src/bootstrap/headers.ts#L1-L41 is probably where those headers are used to make things work and they are not prefixed there

And Stargate link in comment above also lead to unprefixed headers

...options.headers,
},
Expand Down
Loading