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

History routing not compatible with static hosting like GitHub Pages (404 on refresh) #143

Closed
6 tasks done
lukasjuhas opened this issue Jun 20, 2022 · 3 comments
Closed
6 tasks done
Labels
bug Something isn't working

Comments

@lukasjuhas
Copy link

Describe the bug

Hey guys, thanks so much for the amazing package and your hard work in making this possible. We've been trying it out and we have run into an issue.

  • Deploying to Github requires a bit of set up which we've figured out by providing some config for vite:
import { defineConfig } from "vite"

export default defineConfig({
  vite: {
    base: process.env.HISTOIRE_BASE || "/",
  },
})

We pass HISTOIRE_BASE in our Github action workflow.

However, the issue comes when you open up the page in Github pages and then navigate to a specific component story. It works all fine but as soon as you refresh the page you get a 404 page.

Any thoughts on how to go about this?

Reproduction

Repo:
https://github.com/lukasjuhas/histoire-ghpages-repro/

Github pages branch:
https://github.com/lukasjuhas/histoire-ghpages-repro/tree/gh-pages

The url:
https://lukasjuhas.github.io/histoire-ghpages-repro/

To see the error:

  1. Visit https://lukasjuhas.github.io/histoire-ghpages-repro/
  2. Click on the button story page
  3. Refresh the page
  4. You get 404

System Info

All in the repo. Fresh vue 3 setup + hitoire.

Used Package Manager

npm

Validations

@lukasjuhas lukasjuhas added the to triage This issue needs to be triaged label Jun 20, 2022
@lukasjuhas
Copy link
Author

Just to add, I understand that this might be an issue with the way how Github pages work and that they don't really support routes and history... however, it would be great to find a way to get this working as I imagine, people would want to deploy Histoire to Github pages, just as it is possible with Storybook.

@Akryum Akryum added bug Something isn't working and removed to triage This issue needs to be triaged labels Jun 20, 2022
@Akryum Akryum changed the title Deploying to Github Pages using Github Action History routing not compatible with static hosting like GitHub Pages (404 on refresh) Jun 20, 2022
@Akryum Akryum closed this as completed in 1e337e3 Jun 20, 2022
@lukasjuhas
Copy link
Author

Thank you @Akryum ❤️

@samuveth
Copy link

samuveth commented Aug 3, 2023

If anyone is experiencing 404 on refresh on Vercel, you can create a vercel.json and add this as a fix

{
  "rewrites": [
    {
      "source": "/(.*)",
      "destination": "/"
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants