slidevjs / slidev

Presentation Slides for Developers
https://sli.dev
MIT License
32.82k stars 1.33k forks source link

404 after refresh #1256

Closed xmusphlkg closed 8 months ago

xmusphlkg commented 8 months ago

Describe the bug

Thank you for your appreciation; it's indeed a delightful project.

However, I seem to have encountered a minor bug. The presentation appears as expected when showcased on a particular slide. Nevertheless, when attempting to share this specific slide through a link with others or upon refreshing the webpage, a 404 error surfaces. Initially, I presumed it might be a GitHub Pages issue, but to my surprise, the same error persists when employing Netlify for static deployment. Here is the URL in question: https://slides.kangguo.online/20240118_ggplot2_visualzation/44.

While I lack precise details regarding the configuration files for the examples provided on your site, it appears that the examples showcased on your website exhibit proper functionality: https://demo.sli.dev/composable-vue/7?clicks=2)

Desktop (please complete the following information):

antfu commented 8 months ago

If you are deploy to sub-routes, you need to set the SPA fallback manually: https://github.com/slidevjs/slidev/blob/907a593d4184413e607d447202f6879d5b12f51c/netlify.toml#L9-L18

pelikhan commented 3 months ago

@antfu we are deploying to github pages and we are seeing the same behavior. Any hint here?

xmusphlkg commented 3 months ago

@antfu we are deploying to github pages and we are seeing the same behavior. Any hint here?

Netlify is better than GitHub Pages, and is also free.

KermanX commented 3 months ago

@antfu we are deploying to github pages and we are seeing the same behavior. Any hint here?

If you build you slides and deploy them to GitHub Pages, it should works as expected AFAIK. For example, https://kermanx.github.io/10-26-presentation/2

zhuozhiyongde commented 5 days ago

If you are using Nginx, add following code into your config:

location / {
    try_files $uri $uri/ @fallback;
}

location @fallback {
    if ($uri ~* ^/[^/]+$) {
        rewrite ^ /index.html break;
    }
    if ($uri ~* ^/([^/]+)/.*$) {
        set $subdir $1;
        rewrite ^ /$subdir/index.html break;
    }
}