Commit 0c2f0543 authored by wty's avatar wty

重写阿波罗配置获取12

parent 421d3f75
......@@ -8,6 +8,8 @@ const getConfig = ()=>{
return require('../config/prod.json')
case 'test':
return require('../config/test.json')
case 'local':
return 'local'
}
}
......
......@@ -15,42 +15,43 @@ const ssoRouter = require('./routes/sso')
const typeManage = require('./routes/typeManage')
const Eureka = require('eureka-node').default
const DockerApp = require('docker-app-node')
const config = require('../config/getConfig')()
const http = require('http')
const app = express();
// //本地调试代码套装
// let server = http.createServer(app);
// server.listen(3000)
// global.domain = 'http://172.16.227.78:3000'
//
// console.info(global.domain)
//线上服务代码套装
global.domain = 'http://' + os.networkInterfaces()['eth0'][0]['address'] + ':3000'
const dockerApp = new DockerApp({
app,
appType: 'express',
port:3000
})
if (config === 'local'){
let server = http.createServer(app);
server.listen(3000)
global.domain = 'http://172.16.227.78:3000'
}else {
global.domain = 'http://' + os.networkInterfaces()['eth0'][0]['address'] + ':3000'
const dockerApp = new DockerApp({
app,
appType: 'express',
port:3000
})
// 注册Eureka
global.eureka = new Eureka({
port: 3000, // 应用端口号
appName: 'dui123', // 应用名称
services: ['dui123'] // 依赖服务名
})
global.eureka = new Eureka({
port: 3000, // 应用端口号
appName: 'dui123', // 应用名称
services: ['dui123'] // 依赖服务名
})
global.eureka.start().then(() => {
dockerApp.startServer().then(()=>{
console.info('eureka已启动')
console.info('dockerApp已启动')
global.eureka.start().then(() => {
dockerApp.startServer().then(()=>{
console.info('eureka已启动')
console.info('dockerApp已启动')
})
})
})
}
console.info(global.domain)
//
// app.use((req,res, next) => {
// const {sso_ticket} = req.cookies
......@@ -69,6 +70,12 @@ app.use((req, res, next) => {
const header = {
'Content-Type': ''
}
if (config === 'local'){
header['Access-Control-Allow-Credentials'] = true
header['Access-Control-Allow-Origin'] = req.headers.origin || '*'
header['Access-Control-Allow-Headers'] = 'X-Requested-With,Content-Type'
header['Access-Control-Allow-Methods'] = 'PUT,POST,GET,DEconstE,OPTIONS'
}
if (url.includes('static')){
if (url.includes('html')) header["Content-Type"] = 'text/html; charset=utf-8'
......@@ -91,9 +98,6 @@ app.use(cookieParser());
app.engine('html', engines.mustache)
app.set('view engine', 'html')
app.set('views', path.join(__dirname, '/staticFile/build'));
// app.use(favicon(path.join(__dirname, "../static/build/favicon.ico")));
// app.use('/scripts', express.static(path.join(__dirname, 'node_modules')));
// app.use(express.static(path.join(__dirname, 'build')));
app.get('/', function(req, res){
res.type('html')
res.render('index.html');
......
......@@ -20,6 +20,7 @@
text-align: center;
cursor: pointer;
margin: 0 10px 0;
padding: 0 10px;
// border-bottom: 2px solid #cccccc;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment