fix: Correct environment variables and MIME types for production
- Change VITE_SERVER_URL to SERVER_URL in docker-compose - Add dist directory serving for built assets - Configure Express to serve JS modules with correct MIME type - Fix undefined Game Server in containers
This commit is contained in:
@@ -153,8 +153,12 @@ app.post('/api/admin/cancel-game', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serve static files from current directory (AFTER API routes)
|
// Configure MIME types for modules
|
||||||
|
express.static.mime.define({'application/javascript': ['js', 'mjs']});
|
||||||
|
|
||||||
|
// Serve static files from current directory and dist (AFTER API routes)
|
||||||
app.use(express.static('.'));
|
app.use(express.static('.'));
|
||||||
|
app.use(express.static('dist'));
|
||||||
|
|
||||||
// Serve main HTML file for SPA routes
|
// Serve main HTML file for SPA routes
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
|
|||||||
@@ -9,8 +9,12 @@ dotenv.config({ path: `.env.${ENV}` });
|
|||||||
const app = express();
|
const app = express();
|
||||||
const PORT = process.env.PORT || 3000;
|
const PORT = process.env.PORT || 3000;
|
||||||
|
|
||||||
// Serve static files from current directory
|
// Configure MIME types for modules
|
||||||
|
express.static.mime.define({'application/javascript': ['js', 'mjs']});
|
||||||
|
|
||||||
|
// Serve static files from current directory and dist
|
||||||
app.use(express.static('.'));
|
app.use(express.static('.'));
|
||||||
|
app.use(express.static('dist'));
|
||||||
|
|
||||||
// Serve main HTML file
|
// Serve main HTML file
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- PORT=3000
|
- PORT=3000
|
||||||
- VITE_SERVER_URL=http://snatchgame-server:2567
|
- SERVER_URL=http://snatchgame-server:2567
|
||||||
depends_on:
|
depends_on:
|
||||||
- snatchgame-server
|
- snatchgame-server
|
||||||
networks:
|
networks:
|
||||||
@@ -51,7 +51,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- PORT=3001
|
- PORT=3001
|
||||||
- VITE_SERVER_URL=http://snatchgame-server:2567
|
- SERVER_URL=http://snatchgame-server:2567
|
||||||
depends_on:
|
depends_on:
|
||||||
- snatchgame-server
|
- snatchgame-server
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
Reference in New Issue
Block a user