feat: add redirect for non-hash URLs to support HashRouter

This commit is contained in:
plebeius
2025-11-07 12:18:42 +01:00
parent 696f19fcc0
commit dba736efb4
3 changed files with 13 additions and 1 deletions
+6
View File
@@ -10,6 +10,12 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json" />
<title>5chan</title> <title>5chan</title>
<script>
// Redirect non-hash URLs to hash URLs on initial load
if (window.location.pathname && window.location.pathname !== '/' && window.location.pathname !== '/index.html' && !window.location.hash) {
window.location.replace('/#' + window.location.pathname + window.location.search);
}
</script>
</head> </head>
<body> <body>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
+1 -1
View File
@@ -56,7 +56,7 @@
"start": "vite", "start": "vite",
"build": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=false vite build", "build": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=false vite build",
"build:preload": "vite build --config electron/vite.preload.config.js", "build:preload": "vite build --config electron/vite.preload.config.js",
"build-netlify": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" PUBLIC_URL=./ GENERATE_SOURCEMAP=true VITE_COMMIT_REF=$COMMIT_REF CI='' vite build", "build-vercel": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" PUBLIC_URL=./ GENERATE_SOURCEMAP=true VITE_COMMIT_REF=$COMMIT_REF CI='' vite build",
"test": "vitest", "test": "vitest",
"preview": "vite preview", "preview": "vite preview",
"analyze-bundle": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=true vite build && npx source-map-explorer 'dist/assets/*.js'", "analyze-bundle": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=true vite build && npx source-map-explorer 'dist/assets/*.js'",
+6
View File
@@ -0,0 +1,6 @@
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}