zhlajiex commited on
Commit
b0e463e
·
1 Parent(s): 885b766

Fix: Improve routing logic to prevent 404s on custom domains

Browse files
Files changed (1) hide show
  1. backend/server.js +4 -5
backend/server.js CHANGED
@@ -133,11 +133,10 @@ app.get('/sentinel', (req, res) => res.sendFile(path.join(__dirname, 'public', '
133
  app.get('/manifesto', (req, res) => res.sendFile(path.join(__dirname, 'public', 'manifesto.html')));
134
  app.get('/broadcast', (req, res) => res.sendFile(path.join(__dirname, 'public', 'broadcast.html')));
135
 
136
- app.use((req, res, next) => {
137
- if (req.method === 'GET' && !req.path.startsWith('/api')) {
138
- return res.redirect('/');
139
- }
140
- next();
141
  });
142
 
143
  app.get('/api/status/sentinel-history', (req, res) => {
 
133
  app.get('/manifesto', (req, res) => res.sendFile(path.join(__dirname, 'public', 'manifesto.html')));
134
  app.get('/broadcast', (req, res) => res.sendFile(path.join(__dirname, 'public', 'broadcast.html')));
135
 
136
+ // Catch-all for React/Frontend routes should come AFTER specific API/Static routes
137
+ app.get('*', (req, res, next) => {
138
+ if (req.path.startsWith('/api')) return next();
139
+ res.sendFile(path.join(__dirname, 'public', 'index.html'));
 
140
  });
141
 
142
  app.get('/api/status/sentinel-history', (req, res) => {