PLUTON\igor.kreyda commited on
Commit
f3b3e6f
·
1 Parent(s): e9ebe66

fix: normalize WEBAPP_URL to prevent double-pathing (404 error)

Browse files
Files changed (1) hide show
  1. index.js +9 -1
index.js CHANGED
@@ -12,7 +12,15 @@ const { setupBot } = require('./app/bot/bot');
12
 
13
  const app = express();
14
  const PORT = process.env.PORT || 7860;
15
- const WEBAPP_URL = process.env.WEBAPP_URL || 'https://your-domain.com';
 
 
 
 
 
 
 
 
16
 
17
  // --- Express Server Setup ---
18
  app.use(cors());
 
12
 
13
  const app = express();
14
  const PORT = process.env.PORT || 7860;
15
+
16
+ // Normalize WEBAPP_URL: remove trailing slash and common suffixes to avoid double-pathing in bot.js
17
+ let WEBAPP_URL = (process.env.WEBAPP_URL || '').replace(/\/$/, '');
18
+ if (WEBAPP_URL.endsWith('/app/index.html')) {
19
+ WEBAPP_URL = WEBAPP_URL.replace('/app/index.html', '');
20
+ } else if (WEBAPP_URL.endsWith('/app')) {
21
+ WEBAPP_URL = WEBAPP_URL.replace('/app', '');
22
+ }
23
+ if (!WEBAPP_URL) WEBAPP_URL = `http://localhost:${PORT}`;
24
 
25
  // --- Express Server Setup ---
26
  app.use(cors());