No Subfolder in the URL
This commit is contained in:
@@ -14,18 +14,16 @@ const __dirname = dirname(__filename);
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3001;
|
||||
const subfolder = '/ag-beats';
|
||||
const distPath = path.join(__dirname, '../dist');
|
||||
|
||||
const COLORS = ['#F94144', '#F3722C', '#F8961E', '#F9C74F', '#90BE6D', '#43AA8B', '#4D908E', '#577590', '#277DA1'];
|
||||
const getRandomColor = () => COLORS[Math.floor(Math.random() * COLORS.length)];
|
||||
|
||||
app.use(subfolder, express.static(distPath));
|
||||
app.get(subfolder + '/*', (req, res) => res.sendFile(path.join(distPath, 'index.html')));
|
||||
app.get('/', (req, res) => res.redirect(subfolder));
|
||||
app.use(express.static(distPath));
|
||||
app.get('*', (req, res) => res.sendFile(path.join(distPath, 'index.html')));
|
||||
|
||||
const httpServer = http.createServer(app);
|
||||
const wss = new WebSocketServer({ path: '/ag-beats', server: httpServer });
|
||||
const wss = new WebSocketServer({ path: '/', server: httpServer });
|
||||
|
||||
interface ClientInfo {
|
||||
ws: WebSocket;
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useWebSocket(sessionId: string | null) {
|
||||
if (!sessionId || ws.current) return;
|
||||
|
||||
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);
|
||||
|
||||
socket.onopen = () => {
|
||||
|
||||
@@ -15,7 +15,7 @@ export default defineConfig(({ mode }) => {
|
||||
react(),
|
||||
tailwindcss(),
|
||||
],
|
||||
base: '/ag-beats/',
|
||||
base: '/',
|
||||
build: {
|
||||
outDir: '../dist',
|
||||
emptyOutDir: true,
|
||||
|
||||
Reference in New Issue
Block a user