Files
Sebastian "Sebbie" Silbermann 64596d1f53 [test] Fix proxy-request-with-middleware deploy test (#98553)
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:555
2026-09-11 13:43:34 +02:00
..