sapper icon indicating copy to clipboard operation
sapper copied to clipboard

Empty dynamic URL param

Open Fanda36 opened this issue 4 years ago • 2 comments
trafficstars

Describe the bug I created universal route routes/convert/[...format(.*)].svelte for handling every request (convert/*, including convert/). It works on dev server sapper dev --no-hot. When I go to localhost:3000/convert/ then I got result from [...format(.*)].svelte.

image

The problem is if I generate static web NODE_ENV=production sapper export, then mypage.com/convert/ return 404 not found.

image

To Reproduce

  • do a file routes/convert/[...format(.*)].svelte
  • create <a href="convert">test</a> in routes/index.svelte
  • generate export NODE_ENV=production sapper export
  • page myweb.com/convert/ return 404

Expected behavior Page myweb.com/convert/ will be rendered.

Information about your Sapper Installation:

  • The output of npx envinfo --system --npmPackages svelte,sapper,rollup,webpack --binaries --browsers
System:
    OS: Linux 5.9 Manjaro Linux
    CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
    Memory: 836.11 MB / 15.62 GB
    Container: Yes
    Shell: 5.1.0 - /bin/bash
  Binaries:
    Node: 14.15.4 - /usr/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 6.14.11 - /usr/bin/npm
  Browsers:
    Firefox: 84.0.2
  npmPackages:
    sapper: ^0.28.0 => 0.28.10 
    svelte: ^3.17.3 => 3.31.2 
    webpack: ^4.7.0 => 4.46.0
  • Your hosting environment - static

  • If it is an exported (npm run export) or dynamic application - exported

Severity How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of Sapper entirely?

  • I have to have duplicity index.svelte and [...format(.*)].svelte has same content.

Fanda36 avatar Jan 26 '21 20:01 Fanda36

Can you publish a repo?

peopledrivemecrazy avatar Jan 31 '21 07:01 peopledrivemecrazy

Having the same requirements for our app:

  • Routes like /category, /category/color_red, /category/color_red_yellow/size_m

We don't use static export, however, the described above trick with [...args(.*)] doesn't work with a dynamic app too and a workaround with index.svelte + [...args].svelte causing a lot of issues in the state management and transitions, so it would be great if this could be fixed.

I've created a repo with a modified starter template to demonstrate the issue: https://github.com/zimnicky/sapper-empty-route-test

Expected behavior: /hats shouldn't return 404

zimnicky avatar Feb 09 '21 10:02 zimnicky