Skip to content

Commit 209e41d

Browse files
Update Vercel configuration for better SPA routing
- Simplified vercel.json to use rewrites instead of routes - Added explicit build and output directory configuration - This should fix the 404 errors when refreshing pages - Using modern Vercel configuration approach for React SPAs
1 parent ef034c8 commit 209e41d

2 files changed

Lines changed: 13 additions & 42 deletions

File tree

vercel-alternative.json

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,11 @@
11
{
2-
"version": 2,
3-
"name": "syncruncode",
4-
"builds": [
2+
"rewrites": [
53
{
6-
"src": "client/package.json",
7-
"use": "@vercel/static-build",
8-
"config": {
9-
"distDir": "dist",
10-
"buildCommand": "npm run build"
11-
}
4+
"source": "/(.*)",
5+
"destination": "/index.html"
126
}
137
],
14-
"routes": [
15-
{
16-
"src": "/(.*)",
17-
"dest": "/client/dist/$1"
18-
}
19-
],
20-
"env": {
21-
"VITE_API_URL": "https://syncruncode.onrender.com",
22-
"VITE_SOCKET_URL": "https://syncruncode.onrender.com"
23-
},
24-
"functions": {
25-
"client/dist/**": {
26-
"runtime": "nodejs18.x"
27-
}
28-
}
29-
}
8+
"buildCommand": "cd client && npm run build",
9+
"outputDirectory": "client/dist",
10+
"installCommand": "cd client && npm install"
11+
}

vercel.json

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
{
2-
"version": 2,
3-
"builds": [
2+
"buildCommand": "cd client && npm run build",
3+
"outputDirectory": "client/dist",
4+
"installCommand": "cd client && npm install",
5+
"rewrites": [
46
{
5-
"src": "client/package.json",
6-
"use": "@vercel/static-build",
7-
"config": {
8-
"distDir": "dist"
9-
}
10-
}
11-
],
12-
"routes": [
13-
{
14-
"src": "/assets/(.*)",
15-
"dest": "/client/dist/assets/$1"
16-
},
17-
{
18-
"src": "/(.*)",
19-
"dest": "/client/dist/index.html"
7+
"source": "/(.*)",
8+
"destination": "/index.html"
209
}
2110
],
2211
"env": {

0 commit comments

Comments
 (0)