gatsby: github pages 404 error on static files first time
I am new to gatsby and facing an issue with loading static html files.
I have a component called notes.js
that links to some static files like so
export default ({ data }) =>
<div style={{ flex: "1 0 auto" }}>
<Link to={withPrefix("/notes/note1.html")} target="_blank">some note</Link>
</div>
The file is saved at static/notes/note1.html
.
This works fine in development, http://localhost:8000/notes/note1.html
opens as expected when I click on the link.
But when I deploy the same, the first time I click on the link, it goes to github’s 404 page.
But works fine on subsequent clicks.
Have I misconfigured something in gatsby? gatsby repo: https://github.com/subsid/blog-skeleton
Thanks for your great work.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 24 (12 by maintainers)
This is a mistake…
@SleeplessByte I added target=“_blank” and href to http instead of https. It used to give 404 on primerlabs.io, but worked well on www.primerlabs.io. Now, it’s working fine for both.
not stale
On Sat, 19 Jan 2019, 18:16 gatsbot[bot], notifications@github.com wrote:
I’m also facing the same issue, my question is how do you handle the already existing service worker to fix this issue or force refresh to update the changes.
@ykosaka-welyco when you updated
navigateFallbackWhitelist
did you manage to test on a different browser where the service worker hadn’t been updated yet?Yup, that solves the issue. Disabling
gatsby-plugin-offline
seems to cause someother error to do withsw.js
when deployed. (might be cause of my chrome extensions as well) It worked fine on firefox though. Anyways, I’ll dig into this a little more and see if I can get more info. Thanks!Huh… ok! I’m not sure exactly what’s happening under the hood, but I managed to work around this with these steps:
/static/notes/
directory to something else - I chose/static/static-notes
gatsby-plugin-offline
Does that fix it on your side? If you’re able to do some more digging into the source of the problem that’d be very useful!
Hi @peduarte 👋 that suggestion was for @subsid, I don’t know if it’ll help in your case. Could you create a new GitHub issue explaining the error you’re seeing?