dai-shi / waku

⛩️ The minimal React framework
https://waku.gg
MIT License
4.08k stars 108 forks source link

`<a href="/[some_dynamic_page]"/>` will cause 404 in prod mode #536

Closed himself65 closed 3 months ago

himself65 commented 3 months ago

workaround is to use Link

himself65 commented 3 months ago

Seems like it's the issue on dynamic page

dai-shi commented 3 months ago

Thanks for reporting. Can we reproduce it with examples/01_template with changing render: 'dynamic' for path: '/'?

himself65 commented 3 months ago

Thanks for reporting. Can we reproduce it with examples/01_template with changing render: 'dynamic' for path: '/'?

im adding the test case now

himself65 commented 3 months ago

Oh, I think it's my custom app logic issue, here is fallback in waku start

  if (!options.ssr) {
    // history api fallback
    app.use(
      '*',
      serveStatic({
        root: path.join(distDir, publicDir),
        rewriteRequestPath: () => '/',
      }),
    );
  }
dai-shi commented 3 months ago

what's your custom app logic? is your options.ssr false?

himself65 commented 3 months ago

Yeah, I disabled SSR because it's a electron app, which run waku

dai-shi commented 3 months ago

Is it specific to /? I wonder if it causes the same issue with path: '/foo/[id]'. It might be related to #534, which i'm currently working on.

himself65 commented 3 months ago

Closing as this is not a bug in waku, but still need to update the document and cover the test

Solution: https://github.com/dai-shi/waku/issues/536#issuecomment-1963177880

dai-shi commented 3 months ago

Okay, I think I understand the problem. When / is dynamic, we don't create dist/public/index.html, then history api fallback doesn't work. (I will think about it.)

himself65 commented 3 months ago

Okay, I think I understand the problem. When / is dynamic, we don't create dist/public/index.html, then history api fallback doesn't work. (I will think about it.)

Maybe we should fall back to SPA?