skyline-console/config/server.dev.js
Jingwei.Zhang 0213d8c6d6 feat: optimize configuration reading
Add config/config.yaml to set default configurations. Use the config/local_config.yaml to set the custom configurations

Change-Id: I22049e478b6440c765751c8f17663f36f33c277a
2023-05-31 11:41:19 +08:00

32 lines
695 B
JavaScript

const { isObject } = require('lodash');
const { getServerConfig } = require('./utils');
const { server, port, host } = getServerConfig();
const getProxyByMap = (apiMap) => {
const result = {};
Object.keys(apiMap).forEach((key) => {
const value = apiMap[key];
const base = isObject(value) ? value : { target: value };
result[key] = {
...base,
changeOrigin: true,
secure: false,
headers: {
Connection: 'keep-alive',
},
};
});
return result;
};
const apiMap = {
'/api/': server,
};
// eslint-disable-next-line no-console
console.log('apiMap', apiMap);
const proxy = getProxyByMap(apiMap);
module.exports = { proxy, host, port };