Skip to content

[vite-plugin-cloudflare] fix: preserve :authority and port in HTTP/2 requests - #15519

Open
devaniketh wants to merge 2 commits into
cloudflare:mainfrom
devaniketh:fix/vite-plugin-http2-authority-port
Open

[vite-plugin-cloudflare] fix: preserve :authority and port in HTTP/2 requests#15519
devaniketh wants to merge 2 commits into
cloudflare:mainfrom
devaniketh:fix/vite-plugin-http2-authority-port

Conversation

@devaniketh

@devaniketh devaniketh commented Sep 5, 2026

Copy link
Copy Markdown

Fixes #14931.

When Vite dev server is served over HTTPS with HTTP/2 enabled, browsers communicate using HTTP/2 where the host and port are passed via the :authority pseudo-header rather than the HTTP/1.1 Host header.

Previously, request conversion in createRequestForIncomingMessage omitted pseudo-headers when creating the Web Standard Request, causing headers.get("Host") to be null and falling back to "localhost", discarding non-default ports (such as :5173). Consequently, X-Forwarded-Host was not set in toMiniflareRequest, breaking OAuth and Clerk handshake redirects.

This change:

  1. Extracts authority and non-default port from req.headers[":authority"] and req.authority.
  2. Extracts scheme from req.headers[":scheme"] and req.scheme.
  3. Ensures Host header is populated on the created Request.
  4. Falls back to new URL(request.url).host in toMiniflareRequest to guarantee X-Forwarded-Host preserves the host and port.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Internal dev server request adaptation fix.

Devin Review

@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 18d4715

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Sep 5, 2026
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team September 5, 2026 03:17
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/vite-plugin-preserve-authority-port.md: [@cloudflare/wrangler]
  • packages/vite-plugin-cloudflare/src/tests/utils.spec.ts: [@cloudflare/wrangler]
  • packages/vite-plugin-cloudflare/src/utils.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@15519

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15519

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15519

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15519

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@15519

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@15519

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@15519

miniflare

npm i https://pkg.pr.new/miniflare@15519

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15519

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@15519

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@15519

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@15519

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15519

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@15519

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@15519

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@15519

wrangler

npm i https://pkg.pr.new/wrangler@15519

commit: 18d4715

@devaniketh

Copy link
Copy Markdown
Author

@dario-piotrowicz hey can you look into the PR , let me know if there are any changes to made

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

@cloudflare/vite-plugin: HTTPS/HTTP2 Host/:authority handling drops non-default port from request.url (breaks Clerk handshake redirects)

2 participants