Skip to content

Commit cc6754b

Browse files
fix: set GitHub Pages base path to /react-javascript-api/
The Vite base still pointed at the old repo name, causing 404s for JS/CSS on Pages. Also copy index.html to 404.html so client-side routes work on direct navigation. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c5ec007 commit cc6754b

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

vite.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3+
import { copyFileSync } from 'node:fs'
4+
import { resolve } from 'node:path'
35

46
// https://vite.dev/config/
57
export default defineConfig(({ command }) => ({
6-
plugins: [react()],
7-
base: command === 'serve' ? '/' : '/React_Javascript_Api/'
8+
plugins: [
9+
react(),
10+
{
11+
name: 'gh-pages-spa-fallback',
12+
closeBundle() {
13+
const dist = resolve(__dirname, 'dist')
14+
copyFileSync(resolve(dist, 'index.html'), resolve(dist, '404.html'))
15+
},
16+
},
17+
],
18+
base: command === 'serve' ? '/' : '/react-javascript-api/',
819
}))

0 commit comments

Comments
 (0)