Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with trailingSlash and prerendered routes #8755

Closed
yellowby opened this issue Jan 27, 2023 · 4 comments · Fixed by #8766 or #8857
Closed

Issue with trailingSlash and prerendered routes #8755

yellowby opened this issue Jan 27, 2023 · 4 comments · Fixed by #8766 or #8857
Labels
bug Something isn't working low hanging fruit pkg:adapter-node ready to implement please submit PRs for these issues!
Milestone

Comments

@yellowby
Copy link

Describe the bug

I have a website with prerendered pages running via adapter-node. The problem is that users sometimes use trailing slash in URLs. In this case, the loaded page looks like it has no css loaded, but with the correct content. I would expect a redirect to the URL without a trailing slash.

What is the expected behavior in this case?

https://sveltekit-trailing-slash.vercel.app/test

Screenshot 2023-01-27 182023

https://sveltekit-trailing-slash.vercel.app/test/

Screenshot 2023-01-27 182012

Reproduction

Demo: https://sveltekit-trailing-slash.vercel.app/

Repository: https://github.com/yellowby/sveltekit-trailing-slash

Logs

No response

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 38.98 GB / 63.93 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1105.0), Chromium (109.0.1518.69)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.2 => 1.0.2
    @sveltejs/adapter-node: ^1.1.4 => 1.1.4
    @sveltejs/kit: ^1.0.0 => 1.3.1
    svelte: ^3.54.0 => 3.55.1
    vite: ^4.0.0 => 4.0.4

Severity

annoyance

Additional Information

No response

@Rich-Harris Rich-Harris added bug Something isn't working pkg:adapter-vercel Pertaining to the Vercel adapter low hanging fruit labels Jan 27, 2023
@Rich-Harris Rich-Harris added this to the soon milestone Jan 27, 2023
@Rich-Harris
Copy link
Member

It looks like you mean adapter-vercel rather than adapter-node?

The expected behaviour is that /test/ redirects to /test, so that relative asset paths are correct. It looks like the routes config generated by adapter-vercel is incorrect though.

@Rich-Harris Rich-Harris added the ready to implement please submit PRs for these issues! label Jan 27, 2023
dummdidumm pushed a commit that referenced this issue Jan 30, 2023
…Vercel adapter (#8766)

fixes #8755

Adds a redirect for prerendered non-trailing slash routes to adapter-vercel.
Previously, only prerendered trailing slash routes would be added to the redirects list in the vercel config file.
@yellowby
Copy link
Author

@Rich-Harris Sorry for the confusion (should post screenshots from localhost and adapter-node). The issue affects both adapter-node and adapter-vercel.

It looks like you mean adapter-vercel rather than adapter-node?

The expected behaviour is that /test/ redirects to /test, so that relative asset paths are correct. It looks like the routes config generated by adapter-vercel is incorrect though.

@dummdidumm dummdidumm reopened this Jan 30, 2023
@dummdidumm dummdidumm added pkg:adapter-node and removed pkg:adapter-vercel Pertaining to the Vercel adapter labels Jan 30, 2023
@eltigerchino
Copy link
Member

eltigerchino commented Feb 1, 2023

Should the trailing slash redirect logic be moved from the adapters to instead be part of server.respond as a fallback? or a helper function that adapters can use?

@Rich-Harris
Copy link
Member

It is part of server.respond — adapters just need to be careful about not responding with foo/index.html for /foo or foo.html for /foo/, and letting SvelteKit handle the request instead. Unfortunately in the adapter-node case I think this might involve hacking around sirv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low hanging fruit pkg:adapter-node ready to implement please submit PRs for these issues!
Projects
None yet
4 participants