-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
70 lines (56 loc) · 2.06 KB
/
Copy pathserver.js
File metadata and controls
70 lines (56 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import express from 'express'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const app = express()
const port = process.env.PORT || 3000
// Handle Discord redirect BEFORE static files
app.get('/discord', (req, res) => {
console.log('Redirecting to Discord invite')
res.redirect(301, 'https://discord.gg/mQ3u9cps3G')
})
// Handle Discord redirect BEFORE static files
app.get('/invite', (req, res) => {
console.log('Redirecting to Discord invite')
res.redirect(301, 'https://discord.gg/mQ3u9cps3G')
})
// Serve static files
app.use(express.static(join(__dirname, 'dist')))
// Handle specific SPA routes
app.get('/auth/callback', (req, res) => {
console.log('Serving index.html for route: /auth/callback')
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
app.get('/blog', (req, res) => {
console.log('Serving index.html for route: /blog')
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
app.get('/leaderboard', (req, res) => {
console.log('Serving index.html for route: /leaderboard')
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
app.get('/profile/:discordId', (req, res) => {
console.log(`Serving index.html for profile route: /profile/${req.params.discordId}`)
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
app.get('/profile', (req, res) => {
console.log('Serving index.html for profile route: /profile')
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
app.get('/', (req, res) => {
console.log('Serving index.html for route: /')
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
app.get('/rules-rcs', (req, res) => {
console.log('Serving index.html for route: /rules-rcs')
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
// Fallback for any other routes - use a more specific pattern
app.use((req, res) => {
console.log(`Serving fallback for route: ${req.url}`)
res.sendFile(join(__dirname, 'dist', 'index.html'))
})
app.listen(port, () => {
console.log(`Server running on port ${port}`)
})