add ports to config + bind only to localhost

This commit is contained in:
2022-09-13 20:01:19 +02:00
parent 2a7905a5d0
commit 46c8883ea9
2 changed files with 13 additions and 7 deletions

View File

@@ -1,4 +1,6 @@
const config = { const config = {
devPort: 15800,
servicePort: 15801,
urlPrefix: "/mhd", urlPrefix: "/mhd",
openDataKey: 'INSERT_YOUR_OPENDATA_API_KEY_HERE', openDataKey: 'INSERT_YOUR_OPENDATA_API_KEY_HERE',
database: { database: {

View File

@@ -13,8 +13,8 @@ import SocketHandler from "./SocketHandler.js";
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
const devPort = 5000; const devPort = config.devPort;
const servicePort = 5001; const servicePort = config.servicePort;
const staticFilePath = './static' const staticFilePath = './static'
// Development Server Settings // Development Server Settings
@@ -26,6 +26,7 @@ const frontEndDevServerOptions = {
mode: 'development', mode: 'development',
logLevel: 4, logLevel: 4,
serveOptions: { serveOptions: {
host: '127.0.0.1',
port: devPort, port: devPort,
}, },
/* hmrOptions: { /* hmrOptions: {
@@ -51,13 +52,16 @@ app.start();
server.use(config.urlPrefix + '/static', express.static(staticFilePath)); server.use(config.urlPrefix + '/static', express.static(staticFilePath));
const parcelMiddleware = createProxyMiddleware({ const proxyCfg = {
target: `http://localhost:${devPort}/`, target: `http://127.0.0.1:${devPort}/`,
pathRewrite: {'^/mhd' : ''} // TODO: Maybe fix this with Parcel. pathRewrite: {},
}); };
proxyCfg.pathRewrite['^' + config.urlPrefix] = '/'; // TODO: Maybe fix this with Parcel
const parcelMiddleware = createProxyMiddleware(proxyCfg);
server.use('/', parcelMiddleware); server.use('/', parcelMiddleware);
// Run your Express server // Run your Express server
server.listen(servicePort, () => { server.listen(servicePort, '127.0.0.1', () => {
console.log(`Listening to port ${servicePort}...`); console.log(`Listening to port ${servicePort}...`);
}); });