Skip to content

Commit 14e7d6c

Browse files
Fix GitHub Pages routing to redirect directly to explorer
- Configure production router to redirect root path directly to /explorer - Set correct base URL for GitHub Pages routing - Remove need to manually click Explorer button on first load - Maintain development home page for local development
1 parent 556d4ec commit 14e7d6c

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/router/index.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ import HistoryExplorer from '@views/HistoryExplorer.vue'
44

55
// Conditionally import TestingView only in development for build optimization
66

7-
const routes = [
8-
{
7+
// Create routes based on environment
8+
const routes = []
9+
10+
// In production, redirect root directly to explorer
11+
if (!import.meta.env.DEV) {
12+
routes.push({
13+
path: '/',
14+
redirect: '/explorer'
15+
})
16+
} else {
17+
// In development, show home page
18+
routes.push({
919
path: '/',
1020
name: 'Home',
11-
component: HomeView,
12-
// In production, redirect root to explorer
13-
beforeEnter: (to, from, next) => {
14-
if (!import.meta.env.DEV && to.path === '/') {
15-
next('/explorer')
16-
} else {
17-
next()
18-
}
19-
}
20-
},
21+
component: HomeView
22+
})
23+
}
24+
25+
// Add explorer routes
26+
routes.push(
2127
{
2228
path: '/explorer',
2329
name: 'HistoryExplorer',
@@ -29,7 +35,7 @@ const routes = [
2935
component: HistoryExplorer,
3036
props: true
3137
}
32-
]
38+
)
3339

3440
// Only add testing route in development
3541
if (import.meta.env.DEV) {
@@ -49,7 +55,7 @@ if (import.meta.env.DEV) {
4955
}
5056

5157
const router = createRouter({
52-
history: createWebHistory(),
58+
history: createWebHistory(import.meta.env.PROD ? '/historisnap/' : '/'),
5359
routes
5460
})
5561

0 commit comments

Comments
 (0)