No Subfolder in the URL

This commit is contained in:
AG
2025-12-20 20:54:12 +02:00
parent 13029f4277
commit d28b19c053
3 changed files with 5 additions and 7 deletions

View File

@@ -14,18 +14,16 @@ const __dirname = dirname(__filename);
const app = express(); const app = express();
const port = process.env.PORT || 3001; const port = process.env.PORT || 3001;
const subfolder = '/ag-beats';
const distPath = path.join(__dirname, '../dist'); const distPath = path.join(__dirname, '../dist');
const COLORS = ['#F94144', '#F3722C', '#F8961E', '#F9C74F', '#90BE6D', '#43AA8B', '#4D908E', '#577590', '#277DA1']; const COLORS = ['#F94144', '#F3722C', '#F8961E', '#F9C74F', '#90BE6D', '#43AA8B', '#4D908E', '#577590', '#277DA1'];
const getRandomColor = () => COLORS[Math.floor(Math.random() * COLORS.length)]; const getRandomColor = () => COLORS[Math.floor(Math.random() * COLORS.length)];
app.use(subfolder, express.static(distPath)); app.use(express.static(distPath));
app.get(subfolder + '/*', (req, res) => res.sendFile(path.join(distPath, 'index.html'))); app.get('*', (req, res) => res.sendFile(path.join(distPath, 'index.html')));
app.get('/', (req, res) => res.redirect(subfolder));
const httpServer = http.createServer(app); const httpServer = http.createServer(app);
const wss = new WebSocketServer({ path: '/ag-beats', server: httpServer }); const wss = new WebSocketServer({ path: '/', server: httpServer });
interface ClientInfo { interface ClientInfo {
ws: WebSocket; ws: WebSocket;

View File

@@ -15,7 +15,7 @@ export function useWebSocket(sessionId: string | null) {
if (!sessionId || ws.current) return; if (!sessionId || ws.current) return;
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${protocol}//${window.location.host}/ag-beats?sessionId=${sessionId}`; const wsUrl = `${protocol}//${window.location.host}/?sessionId=${sessionId}`;
const socket = new WebSocket(wsUrl); const socket = new WebSocket(wsUrl);
socket.onopen = () => { socket.onopen = () => {

View File

@@ -15,7 +15,7 @@ export default defineConfig(({ mode }) => {
react(), react(),
tailwindcss(), tailwindcss(),
], ],
base: '/ag-beats/', base: '/',
build: { build: {
outDir: '../dist', outDir: '../dist',
emptyOutDir: true, emptyOutDir: true,