Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import express from 'express';
import { createServer } from 'vite';
import fs from 'fs';
import proxy from './proxy.js';

Expand All @@ -12,6 +11,7 @@ async function startServer() {
// Setup Vite middleware (development only)
let vite;
if (!isProduction) {
const { createServer } = await import('vite');
vite = await createServer({
server: { middlewareMode: true },
appType: 'custom',
Expand Down Expand Up @@ -52,12 +52,12 @@ async function startServer() {
// SPA routing - must be last!
if (isProduction) {
// Production: serve pre-built index.html
app.get('/*', (req, res) => {
app.get('/{*path}', (req, res) => {
res.sendFile('index.html', { root: './dist' });
});
} else {
// Development: use Vite to transform index.html
app.get('/*', async (req, res) => {
app.get('/{*path}', async (req, res) => {
try {
const template = await vite.transformIndexHtml(
req.originalUrl,
Expand Down
2 changes: 1 addition & 1 deletion server/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ console.log(`Proxy API requests to: ${apiURL}`);
* Proxy all API requests to the worlddriven/core backend
* Converts sessionId cookie to Authorization header
*/
router.all('*', async (req, res) => {
router.all('/{*path}', async (req, res) => {
try {
// Extract sessionId from cookie and convert to Authorization header
let authorization;
Expand Down