forked from gitea_admin/simple-node
frontend
This commit is contained in:
17
frontend/index.js
Normal file
17
frontend/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
const backendUrl = process.env.BACKEND_URL || 'http://localhost:3001';
|
||||
|
||||
app.get('/config.js', (req, res) => {
|
||||
res.set('Content-Type', 'application/javascript');
|
||||
res.send(`window.BACKEND_URL = "${backendUrl}";`);
|
||||
});
|
||||
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Frontend service listening at http://localhost:${port}`);
|
||||
console.log(`Configured to use backend at: ${backendUrl}`);
|
||||
});
|
||||
Reference in New Issue
Block a user