Skip to content

Commit 6dd3749

Browse files
committed
lgtm ✅
1 parent 401aa4c commit 6dd3749

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

js/server.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ app.use(rateLimit({
1212
max: 100 // limit each IP to 100 requests per windowMs
1313
}));
1414

15-
// Add Vercel-specific configuration
15+
// Serve static files from root directory
1616
app.use(express.static(path.join(__dirname, '../')));
1717

18-
// Update static paths
19-
app.use('/static', express.static(path.join(__dirname, '..', 'public')));
20-
app.use('/css', express.static(path.join(__dirname, '..', 'css')));
21-
app.use('/js', express.static(path.join(__dirname, '..', 'js')));
18+
// Serve specific directories
19+
app.use('/js', express.static(path.join(__dirname)));
20+
app.use('/css', express.static(path.join(__dirname, '../css')));
21+
app.use('/public', express.static(path.join(__dirname, '../public')));
2222

2323
app.get('/', (req, res) => {
2424
res.sendFile(path.join(__dirname, '..', 'public', 'index.html'))
@@ -64,9 +64,9 @@ app.use((err, req, res, next) => {
6464
res.status(500).send('Something broke!');
6565
});
6666

67-
// Add catch-all route for SPA
67+
// Handle SPA routing
6868
app.get('*', (req, res) => {
69-
res.sendFile(path.join(__dirname, '..', 'public', 'index.html'));
69+
res.sendFile(path.join(__dirname, '../public/index.html'));
7070
});
7171

7272
const PORT = process.env.PORT || 3000;

js/snow.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function initSnow() {
1717
const vertices = [];
1818
const textureLoader = new THREE.TextureLoader();
1919

20-
const sprite = textureLoader.load('/public/snowflake.png');
20+
const sprite = textureLoader.load('/snowflake.png');
2121

2222
for (let i = 0; i < 1000; i++) {
2323
const x = Math.random() * 2000 - 1000;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "2.1.0",
44
"main": "server.js",
55
"scripts": {
6+
"build": "node js/server.js",
67
"start": "node js/server.js",
78
"dev": "nodemon js/server.js"
89
},

vercel.config vercel.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@
66
"use": "@vercel/node"
77
},
88
{
9-
"src": "public/**/*",
9+
"src": "public/**",
1010
"use": "@vercel/static"
1111
}
1212
],
1313
"routes": [
1414
{
1515
"src": "/api/(.*)",
16-
"dest": "js/server.js"
16+
"dest": "/js/server.js"
17+
},
18+
{
19+
"src": "/js/(.*)",
20+
"dest": "/js/$1"
21+
},
22+
{
23+
"src": "/css/(.*)",
24+
"dest": "/css/$1"
1725
},
1826
{
1927
"src": "/(.*)",
20-
"dest": "public/$1"
28+
"dest": "/public/$1"
2129
}
2230
]
2331
}

0 commit comments

Comments
 (0)