open-next icon indicating copy to clipboard operation
open-next copied to clipboard

[BUG] request.url is https when running locally with http

Open sommeeeer opened this issue 4 months ago • 1 comments

request.url in route handlers is with https when you are actually running in http. This can happen when you run OpenNext locally or in wrangler dev.

We also have a test for this. It will fail when you run the E2E with local dev overrides. In the Cloudflare adapter they skip these tests for now.

It is correct in the middleware BTW.

sommeeeer avatar Aug 30 '25 21:08 sommeeeer

The issue seems to be these lines in next/dist/server/next-server.js.

this.fetchHostname and this.port is undefined in our case.

this.nextConfig.experimental.trustHostHeader is also true, so it will set initUrl with https no matter what.

sommeeeer avatar Aug 30 '25 21:08 sommeeeer