kit icon indicating copy to clipboard operation
kit copied to clipboard

Inconsistent trailingSlash behaviour in adapter-node

Open jjgmckenzie opened this issue 2 years ago • 0 comments

Describe the bug

Using adapter-node, when directed by an anchor link

<!-- +page.svelte -->
<a href="/trailing-slash/">Go to a page with trailing slash; note that the href contains a trailing slash.</a>

to /trailing-slash/ with

//+page.server.ts
export const trailingSlash = 'always';

The page will redirect, incorrectly, to /trailing-slash - breaking all relative links. The page will correctly display and redirect to /trailing-slash/ with a trailing slash when refreshed. The behaviour occurs as expected in vite, meaning that the bug can only be diagnosed after the build is deployed.

Reproduction

https://github.com/jjgmckenzie/SvelteKit-Node-Adapter-Trailing-Slash-Bug

Reproduction:

  1. Build with vite and run a node server with the built folder.
  2. Go to / , click the anchor link
  3. It will redirect to /trailing-slash instead of /trailing-slash/ when built and ran with node-adapter, but redirects normally when in a vite development server

Logs

No response

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 759.26 MB / 7.68 GB
  Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.6.5 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1702.0), Chromium (112.0.1722.58)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @sveltejs/adapter-node: ^1.2.4 => 1.2.4
    @sveltejs/kit: ^1.18.0 => 1.18.0
    svelte: ^3.59.1 => 3.59.1
    vite: ^4.3.8 => 4.3.8

Severity

serious, but I can work around it

Additional Information

No response

jjgmckenzie avatar May 19 '23 00:05 jjgmckenzie