Skip to content

Commit 0ef95e8

Browse files
fix for github page
1 parent 1205677 commit 0ef95e8

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

frontend/index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Career Guidance Chatbot</title>
7-
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7+
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
8+
<script>
9+
(function(l) {
10+
if (l.search && l.search[1] === '/') {
11+
var decoded = l.search.slice(1).split('&').map(function(s) {
12+
return s.replace(/~and~/g, '&');
13+
}).join('?');
14+
window.history.replaceState(null, null, l.pathname.replace(/\/$/, '') + decoded + l.hash);
15+
}
16+
}(window.location));
17+
</script>
818
</head>
919
<body>
1020
<div id="root"></div>
11-
<script type="module" src="/src/main.jsx"></script>
21+
<script type="module" src="./src/main.jsx"></script>
1222
</body>
1323
</html>

frontend/public/404.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Redirecting...</title>
7+
<script type="text/javascript">
8+
(function() {
9+
var l = window.location;
10+
var segmentCount = 0;
11+
if (l.hostname.endsWith('github.io')) {
12+
segmentCount = 1;
13+
}
14+
var pathSegments = l.pathname.split('/').slice(0, 1 + segmentCount).join('/');
15+
l.replace(
16+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
17+
pathSegments + '/?/' +
18+
l.pathname.slice(1).split('/').slice(segmentCount).join('/') +
19+
l.search.replace(/&/g, '~and~') + l.hash
20+
);
21+
})();
22+
</script>
23+
</head>
24+
<body></body>
25+
</html>

frontend/src/App.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { applyTheme, getStoredTheme } from './theme';
1111
import Explore from './pages/Explore';
1212

1313
export default function App() {
14+
const baseUrl = import.meta.env.BASE_URL || '/';
15+
const routerBase = baseUrl === './' ? '/' : baseUrl;
1416
const [showSplash, setShowSplash] = useState(() => localStorage.getItem('showSplash') !== 'false');
1517
const [splashVisible, setSplashVisible] = useState(showSplash);
1618

@@ -26,7 +28,7 @@ export default function App() {
2628
}, [showSplash]);
2729

2830
return (
29-
<BrowserRouter>
31+
<BrowserRouter basename={routerBase}>
3032
<div className="min-h-screen bg-[radial-gradient(circle_at_top_left,_var(--c-accent-soft)_0,_var(--c-bg)_45%,_var(--c-bg)_100%)] text-[var(--c-text)]">
3133
<a href="#main" className="sr-only focus:not-sr-only focus:fixed focus:top-3 focus:left-3 focus:z-50 bg-white px-3 py-2 rounded shadow">
3234
Skip to main content

frontend/vite.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33

44
export default defineConfig({
5+
base: './',
56
plugins: [react()],
67
server: {
78
port: 5173,

0 commit comments

Comments
 (0)