Skip to content

Commit

Permalink
fix: expect renamed debug headers
Browse files Browse the repository at this point in the history
  • Loading branch information
serhalp committed Feb 26, 2025
1 parent f3e24b1 commit 406279e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion edge-runtime/lib/headers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const InternalHeaders = {
NFDebugLogging: 'x-nf-debug-logging',
NFRequestID: 'x-nf-request-id',
NFRequestID: 'debug--nf-request-id',
}

// Next 13 supports request header mutations and has the side effect of prepending header values with 'x-middleware-request'
Expand Down
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
16 changes: 8 additions & 8 deletions tests/utils/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,18 @@ 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:',
'x-nf-request-id': v4(),
'debug-x-nf-passthrough': 'passthrough',
'debug-x-nf-passthrough-host': passthroughHost,
'debug-x-nf-passthrough-proto': 'http:',
'debug-x-nf-request-id': v4(),
...options.headers,
},
})
Expand Down

0 comments on commit 406279e

Please sign in to comment.