Skip to content

request.url is 'https://localhost' with no port when https is enabled in framework mode #14694

@phiggins

Description

@phiggins

Reproduction

https://github.com/phiggins/react-router-https-url-bug

  1. Clone https://github.com/phiggins/react-router-https-url-bug because apparently https does not work on StackBlitz
  2. npm i && npm run dev
  3. Access the site in a browser or via curl:
    $ curl --silent --cacert node_modules/.vite/basic-ssl/_cert.pem https://localhost:5173

System Info

System:
    OS: Linux 6.16 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (32) x64 Intel(R) Core(TM) i9-14900HX
    Memory: 35.35 GB / 94.13 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 24.7.0 - /home/phiggins/.asdf/installs/nodejs/24.7.0/bin/node
    npm: 11.5.1 - /home/phiggins/.asdf/plugins/nodejs/shims/npm
    pnpm: 10.24.0 - /home/phiggins/.asdf/installs/nodejs/24.7.0/bin/pnpm
  Browsers:
    Chrome: 141.0.7390.107
    Firefox: 146.0
    Firefox Developer Edition: 146.0
  npmPackages:
    @react-router/dev: ^7.7.1 => 7.11.0
    @react-router/node: ^7.7.1 => 7.11.0
    @react-router/serve: ^7.7.1 => 7.11.0
    react-router: ^7.7.1 => 7.11.0
    vite: ^6.3.3 => 6.4.1

Used Package Manager

npm

Expected Behavior

The entire URL to be output with port.

Actual Behavior

The port is not included:

$ curl --silent --cacert node_modules/.vite/basic-ssl/_cert.pem https://localhost:5174 | jq
{
  "url": "https://localhost/"
}

Notes

I believe I fixed the root cause in node-fetch-server and this was released in version v0.13.0: https://github.com/remix-run/remix/releases/tag/node-fetch-server%400.13.0. However @timdorr indicated in #14010 that this would not be a simple upgrade:

Unfortunately, we're blocked on the fact that the newer version is ESM-only, which would require a breaking change to support: https://github.com/remix-run/remix/releases/tag/node-fetch-server%400.11.0

I'd be happy to add a workaround in react-router until the package upgrade can be done.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions