remix icon indicating copy to clipboard operation
remix copied to clipboard

Single Fetch: redirects do not strip basename

Open oxc opened this issue 1 year ago • 0 comments

Reproduction

  1. Go to https://stackblitz.com/edit/remix-run-remix-css5co?file=vite.config.ts
  2. Open the preview in a new Tab (to see the URL changes)
  3. Append /demoBasename to end of the the preview URL to load the root route
  4. Click on the button
  5. Note that the URL contains the demoBasename twice

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 8.66 GB / 15.48 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.12.2 - /usr/local/bin/node
    Yarn: 4.2.2 - /usr/local/bin/yarn
    npm: 10.5.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 122.0.6261.128

Envinfo for some reason does not output the package versions, so here they are:

  resolution: "@remix-run/dev@npm:2.9.2"
  resolution: "@remix-run/express@npm:2.9.2"
  resolution: "@remix-run/node@npm:2.9.2"
  resolution: "@remix-run/react@npm:2.9.2"
  resolution: "@remix-run/router@npm:1.16.1"
  resolution: "@remix-run/serve@npm:2.9.2"
  resolution: "@remix-run/server-runtime@npm:2.9.2"
  resolution: "@remix-run/web-blob@npm:3.1.0"
  resolution: "@remix-run/web-fetch@npm:4.4.2"
  resolution: "@remix-run/web-file@npm:3.1.0"
  resolution: "@remix-run/web-form-data@npm:3.1.0"
  resolution: "@remix-run/web-stream@npm:1.1.0"
  resolution: "vite-node@npm:1.6.0"
  resolution: "vite-tsconfig-paths@npm:4.3.2"
  resolution: "vite@npm:5.2.11"

Used Package Manager

yarn

Expected Behavior

The page should load the route at /demoBasename/demo and show "It works!"

Actual Behavior

The page tries to load /demoBasename/demoBasename/demo and shows a 404 error.

Possibly related code

Perhaps this line could use a stripBasename? Or use X-Remix-Redirect header? https://github.com/remix-run/remix/blob/c3efad31a9805cc2387f719917e0e7126cc792fc/packages/remix-server-runtime/single-fetch.ts#L438

oxc avatar Jun 07 '24 22:06 oxc