Commit 64596d1
authored
[test] Fix
The fixture's API route proxies the incoming request to
`http://<host>/api/post`. On Vercel, that plain-HTTP hop hits the edge's
http→https upgrade and the handler pipes the resulting 308 back to the
test client, which then has to replay the POST body across the redirect.
Node.js' fetch implementation cannot replay bodies across 307/308
redirects and fails the request with
`UND_ERR_REQ_CONTENT_LENGTH_MISMATCH`, which broke this test in deploy
mode after the test harness switched from `node-fetch` to global `fetch`
in #98195.
This change proxies over `https` when `VERCEL_URL` is set so no
client-visible redirect occurs, while local dev and start modes are
unaffected since they keep using plain HTTP.
Fixes
```
TypeError: fetch failed
29 | 'x-custom-header': 'some value',
30 | }
> 31 | const res = await fetchViaHTTP(next.url, `api`, '', {
| ^
32 | method: method.toUpperCase(),
33 | headers,
34 | body: method.toLowerCase() !== 'get' ? body : undefined,
at Object.<anonymous> (e2e/proxy-request-with-middleware/test/index.test.ts:31:19)
Cause:
RequestContentLengthMismatchError: Request body length does not match content-length header
```
--
https://github.com/vercel/next.js/actions/runs/34543344283/job/103105861941#step:35:555proxy-request-with-middleware deploy test (#98553)1 parent 033bc32 commit 64596d1
2 files changed
Lines changed: 4 additions & 1 deletion
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
0 commit comments