Extensions still necessary for Github.io History Mode? #18226
-
|
Reiterate the question at the bottom of https://dev.to/quasar/publish-your-quasar-spa-on-github-io-with-history-mode-20h2 --
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Short answer: No, the 404.html hack is no longer necessary for most cases. GitHub Pages now supports single-page application routing natively if you use a custom 404.html that redirects to your index. But more importantly, if you're deploying to a custom domain (not For
// quasar.config.js
build: {
afterBuild() {
const fs = require("fs");
fs.copyFileSync("dist/spa/index.html", "dist/spa/404.html");
}
}
build: {
publicPath: "/your-repo-name/"
}And set the base in your Vue Router config: const Router = createRouter({
history: createWebHistory("/your-repo-name/"),
routes,
});If you're using The old redirect-via-JavaScript-in-404.html approach from that article is outdated. The |
Beta Was this translation helpful? Give feedback.
Short answer: No, the 404.html hack is no longer necessary for most cases.
GitHub Pages now supports single-page application routing natively if you use a custom 404.html that redirects to your index. But more importantly, if you're deploying to a custom domain (not
username.github.io/repo), history mode works out of the box because GitHub Pages servesindex.htmlfor any path that doesn't match a file.For
username.github.io/repodeployments (project pages), you still need the404.htmltrick since GitHub doesn't do SPA fallback on subpaths. Here's the minimal setup:dist/index.htmltodist/404.htmlas part of your build: