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

404 Page not found is thrown if using ISR in route with slug #9459

Closed
tonprince opened this issue Mar 20, 2023 · 2 comments · Fixed by #9470
Closed

404 Page not found is thrown if using ISR in route with slug #9459

tonprince opened this issue Mar 20, 2023 · 2 comments · Fixed by #9470
Labels
bug Something isn't working pkg:adapter-vercel Pertaining to the Vercel adapter
Milestone

Comments

@tonprince
Copy link

tonprince commented Mar 20, 2023

Describe the bug

I have the following page structure: /Transfers/From-[from]/To-[to]/By-[by]

Under the page folder By-[by] I added a +page.server.js with ISR enabled:

export const config = {
  isr: {
    expiration: false,
    bypassToken: BYPASS_TOKEN,
    allowQuery: []
  }
};

When I run the application locally with npm run dev or npm run preview the page is found and rendered correctly. But when deploying to Vercel a 404 error is thrown.

Reproduction

Visit https://sveltekit-isr-demo.vercel.app/Transfers/From-Krabi-sss/To-Samui/By-Train
Github: https://github.com/tonprince/sveltekit-isr-demo

Logs

No response

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M2
    Memory: 144.55 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
    npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
  Browsers:
    Chrome: 111.0.5563.64
    Firefox: 111.0
    Safari: 16.3
  npmPackages:
    @sveltejs/adapter-vercel: ^2.4.0 => 2.4.0 
    @sveltejs/kit: ^1.12.0 => 1.12.0 
    svelte: ^3.57.0 => 3.57.0 
    vite: ^4.2.1 => 4.2.1

Severity

blocking all usage of SvelteKit

Additional Information

No response

@tonprince
Copy link
Author

When I use the [...slug] syntax it seems to work but there is another issue when trying to read the slug and use it to load a firestore document. It strangely contains the '/__data.json' suffix when I click on a link which points to this ISR route.

As a workaround I just remove this suffix in order to get the url.

export const load = async ({ params }) => {
    let url = `/Transfers/${params.slug}`;
    url = url.replace("/__data.json", "");
    ...
    // load data from firestore with url
})

@dummdidumm dummdidumm added bug Something isn't working pkg:adapter-vercel Pertaining to the Vercel adapter labels Mar 21, 2023
@dummdidumm dummdidumm added this to the soon milestone Mar 21, 2023
@dummdidumm
Copy link
Member

When looking at what the SvelteKit runtime is invoked with it's /Transfers/Krabi-sss/Samui/Train - the static parts of the route segments are missing.

Rich-Harris pushed a commit that referenced this issue Apr 17, 2023
…#9470)

* fix: constructor correct pathname for isr from route with nested params

fixes #9459

* remove extraneous slashes

* typo

* remove logging

---------

Co-authored-by: Rich Harris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:adapter-vercel Pertaining to the Vercel adapter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants