Skip to content

Commit e270811

Browse files
authored
fix: strip internal middleware header from responses (#160)
1 parent 519a991 commit e270811

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

edge-runtime/lib/response.ts

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export const buildResponse = async ({
139139
}
140140

141141
if (res.headers.get('x-middleware-next') === '1') {
142+
res.headers.delete('x-middleware-next')
142143
return addMiddlewareHeaders(context.next(), res)
143144
}
144145
return res

src/run/handlers/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default async (request: Request) => {
6666
// The side effect is that responses which do contain data will not be streamed to the client,
6767
// but that's fine for redirects.
6868
// TODO: Remove once a fix has been rolled out.
69-
if (response.status > 300 && response.status < 400) {
69+
if ((response.status > 300 && response.status < 400) || response.status >= 500) {
7070
const body = await response.text()
7171
return new Response(body || null, response)
7272
}

tests/netlify-e2e.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,25 @@
116116
"test/e2e/basepath.test.ts": {
117117
"flakey": [
118118
"basePath should not update URL for a 404",
119-
"basePath should handle 404 urls that start with basePath"
119+
"basePath should handle 404 urls that start with basePath",
120+
"basePath should show 404 for page not under the /docs prefix"
120121
]
121122
},
122123
"test/e2e/app-dir/app/index.test.ts": {
123124
"flakey": [
124125
"app dir - basic should return the `vary` header from edge runtime",
125126
"app dir - basic should return the `vary` header from pages for flight requests"
126127
]
128+
},
129+
"test/e2e/app-dir/conflicting-page-segments/conflicting-page-segments.test.ts": {
130+
"flakey": [
131+
"conflicting-page-segments should throw an error when a route groups causes a conflict with a parallel segment"
132+
]
133+
},
134+
"test/e2e/app-dir/actions-navigation/index.test.ts": {
135+
"flakey": [
136+
"app-dir action handling should handle actions correctly after following a relative link"
137+
]
127138
}
128139
},
129140
"rules": {
@@ -168,7 +179,8 @@
168179
"test/e2e/trailingslash-with-rewrite/index.test.ts",
169180
"test/e2e/transpile-packages/index.test.ts",
170181
"test/e2e/typescript-version-no-warning/typescript-version-no-warning.test.ts",
171-
"test/e2e/typescript-version-warning/typescript-version-warning.test.ts"
182+
"test/e2e/typescript-version-warning/typescript-version-warning.test.ts",
183+
"test/e2e/app-dir/app/useReportWebVitals.test.ts"
172184
]
173185
}
174186
}

0 commit comments

Comments
 (0)