Skip to content

[test] Fix proxy-request-with-middleware deploy test - #98553

Merged
eps1lon merged 1 commit into
canaryfrom
sebbie/deploy-test-node-fetch
Sep 11, 2026
Merged

[test] Fix proxy-request-with-middleware deploy test#98553
eps1lon merged 1 commit into
canaryfrom
sebbie/deploy-test-node-fetch

Conversation

@eps1lon

@eps1lon eps1lon commented Sep 11, 2026

Copy link
Copy Markdown
Member

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

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 6011e03

@eps1lon
eps1lon force-pushed the sebbie/deploy-test-node-fetch branch from 4be23bb to 29a8028 Compare September 11, 2026 11:00
@eps1lon
eps1lon force-pushed the sebbie/deploy-test-node-fetch branch from 29a8028 to 6011e03 Compare September 11, 2026 11:07
import { fetchViaHTTP } from 'next-test-utils'
import { FileRef, nextTestSetup } from 'e2e-utils'

// forceful deploy test v1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

change detection is currently crude so this was required to get confirmation from a real run: https://github.com/vercel/next.js/actions/runs/34592487556/job/103242566944?pr=98553#step:35:102

@eps1lon
eps1lon requested a review from unstubbable September 11, 2026 11:33
@eps1lon
eps1lon marked this pull request as ready for review September 11, 2026 11:33
@eps1lon
eps1lon merged commit 64596d1 into canary Sep 11, 2026
118 checks passed
@eps1lon
eps1lon deleted the sebbie/deploy-test-node-fetch branch September 11, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants