diff --git a/server/config.yaml b/server/config.yaml index e24d04e0..fea4708c 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -5,6 +5,6 @@ proxy: prometheus: target: "192.168.8.157:9090" nebulaServer: - ip: "192.168.8.145", + ip: "192.168.8.145" port: 9669 \ No newline at end of file diff --git a/server/dev-server.ts b/server/dev-server.ts index d5c59630..99489d0d 100644 --- a/server/dev-server.ts +++ b/server/dev-server.ts @@ -4,13 +4,23 @@ import webpackDevMiddleware from 'webpack-dev-middleware'; import { createProxyMiddleware } from 'http-proxy-middleware'; import history from 'connect-history-api-fallback'; import fs from 'fs'; -import path from 'path'; - +import path from "path"; +const yaml = require('js-yaml'); import config from '../config/webpack.config.dev'; import pkg from '../package.json'; +let _config = {} as any; +try { + let fileContents = fs.readFileSync(path.join(__dirname, './config.yaml'), 'utf8'); + _config = yaml.load(fileContents); +} catch (e) { + console.log(e); + throw new Error(); +} + const app = express(); const compiler = webpack(config); +const { nebulaServer } = _config; app.use(history()); @@ -44,11 +54,15 @@ app.get('/api/app', (_req, res) => { }); app.get('/api/config/custom', async (_req, res) => { - const data = await fs.readFileSync(path.join(__dirname, '../static/custom.json'), 'utf8'); - if (data) { + if (nebulaServer) { res.send({ code: 0, - data: JSON.parse(data) + data: { + connection: nebulaServer, + alias: { + "ip:port": "instance1" + }, + } }); } else { res.send({ diff --git a/server/server.js b/server/server.js index d0438f68..c41198fe 100755 --- a/server/server.js +++ b/server/server.js @@ -6,7 +6,7 @@ const pkg = require('../package.json'); const yaml = require('js-yaml'); let config = {}; try { - let fileContents = fs.readFileSync('config.yaml', 'utf8'); + let fileContents = fs.readFileSync(path.join(__dirname, './config.yaml'), 'utf8'); config = yaml.load(fileContents); } catch (e) { console.log(e); @@ -56,7 +56,7 @@ app.get('/api/app', (_req, res) => { }); app.get('/api/config/custom', async (_req, res) => { - if (data) { + if (nebulaServer) { res.send({ code: 0, data: {