79079561

Date: 2024-10-11 19:55:22
Score: 5
Natty:
Report link

Actually it is 2024 and I have same issue. for some reasons when I use hash router with baseName its just a blank page with no errors

import { BrowserRouter, HashRouter } from "react-router-dom";

<HashRouter basename={import.meta.env.VITE_BASE_URL}>
      <Suspense fallback={<div>Loading...</div>}>
        <AppResolver />
      </Suspense>
    </HashRouter>

my vite config is next

export default defineConfig(({ mode }) => {
prefix.
  const env = loadEnv(mode, process.cwd(), "");

  return {
    plugins: [
      react(),
      ...
    ],
    build: {
      outDir: "./dist",
    },
    base: env.VITE_BASE_URL || "/",
  };
});

and in package.json file I have a string "homepage": "." Which is all works with browser router but not hash. I decided to try has router since GH pages not working great with SPA's. So I'm confused. any ideas, solutions how to run hasrouter on GH pages?

Reasons:
  • Blacklisted phrase (1): any ideas
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I have same issue
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: David