QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.85k stars 1.31k forks source link

[🐞] Dynamic routes return 404s in static html builds #4091

Closed duncan1a closed 5 months ago

duncan1a commented 1 year ago

Which component is affected?

Qwik-city [routing]

... Or possibly qwik runtime

Describe the bug

I'm building for firebase hosting, so I'm doing static HTML builds.

When I have a dynamic route it's returning 404s. When I run the dev server with npm run dev they work fine. It doesn't look like it's building the html files for the dynamic routes

Screenshot 2023-05-07 at 17 04 30

Reproduction

https://corrineskitchen-dev.web.app/contact/test

Steps to reproduce

Eg, I have a contact page routes/contact/index.tsx. If I make a dynamic route routes/contact/[test]/index.tsx which is just a component that returns "Hello Qwik" - so as simple as possible, I get a 404 in the production build.

The same happens if the route is only a dynamic route, eg: routes/post/[id]/index.tsx

image

The result from the production build

Screenshot 2023-05-07 at 11 48 25

With the dev server it works fine:

Screenshot 2023-05-07 at 11 47 44

System Info

System:
    OS: macOS 13.3.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 21.63 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.1.0 - /usr/local/bin/node
    npm: 9.6.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 112.0.5615.137
    Edge: 112.0.1722.68
    Firefox: 112.0.2
    Safari: 16.4
  npmPackages:
    @builder.io/qwik: ^1.0.0 => 1.0.0 
    @builder.io/qwik-city: ^1.0.0 => 1.0.0 
    @builder.io/sdk-qwik: ^0.3.0 => 0.3.0 
    undici: 5.14.0 => 5.14.0 
    vite: 4.0.3 => 4.0.3

Additional Information

duncan1a commented 1 year ago

I've reproduced this with a fresh v1 qwik app. All I did was add a dynamic route under the /demo/flower/ route that comes with the initial setup. I've uploaded it here including the /dist folder

https://github.com/duncan1a/qwik-v1

image

I've run it with npm/http-server ( https://www.npmjs.com/package/http-server/v/13.0.1 )

image
othy54 commented 1 year ago

Have the same problem !

othy54 commented 1 year ago

Solved the problem by using Netlify Edge ^^

ronaldruzicka commented 1 year ago

I have the same problem. Probably I will also use the edge adapter, but would be nice to have this fixed

rkanani108 commented 5 months ago

@othy54 Can you please explain here...how to be solved it? I'm also facing same issue.

othy54 commented 5 months ago

@othy54 Can you please explain here...how to be solved it? I'm also facing same issue.

npm run qwik add netlify-edge

PatrickJS commented 5 months ago

this is because when rendering static pages you need to know how to get the data https://qwik.dev/docs/guides/static-site-generation/#dynamic-ssg-routes

gioboa commented 5 months ago

Thanks @PatrickJS for your help