serverStart
This commit is contained in:
parent
fe0b84e7c0
commit
182e748172
|
|
@ -22,12 +22,10 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
|
|||
const socketOption = {
|
||||
path: connector.getSubscribeRouter(),
|
||||
};
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
socketOption.cors = {
|
||||
origin: '*',
|
||||
allowedHeaders: ["oak-cxt"],
|
||||
};
|
||||
}
|
||||
socketOption.cors = {
|
||||
origin: '*',
|
||||
allowedHeaders: ["oak-cxt"],
|
||||
};
|
||||
const io = new socket_io_1.Server(httpServer, socketOption);
|
||||
if (process.env.PM2_STATUS) {
|
||||
// pm2环境下要接入clusterAdapter
|
||||
|
|
@ -63,7 +61,7 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
|
|||
const router = new koa_router_1.default();
|
||||
const serverConfig = require(path_1.default.join(path, '/configuration/server.json'));
|
||||
// 如果是开发环境,允许options
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (true) {
|
||||
koa.use(async (ctx, next) => {
|
||||
ctx.set('Access-Control-Allow-Origin', '*');
|
||||
ctx.set('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With, oak-cxt, oak-aspect');
|
||||
|
|
|
|||
|
|
@ -29,14 +29,12 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
|
|||
const socketOption: any = {
|
||||
path: connector.getSubscribeRouter(),
|
||||
};
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
socketOption.cors = {
|
||||
origin: '*', // 应该只有debug模式存在
|
||||
allowedHeaders: ["oak-cxt"],
|
||||
};
|
||||
}
|
||||
socketOption.cors = {
|
||||
origin: '*', // 允许跨域访问
|
||||
allowedHeaders: ["oak-cxt"],
|
||||
};
|
||||
const io = new Server(httpServer, socketOption);
|
||||
if (process.env.PM2_STATUS) {
|
||||
if (process.env.PM2_STATUS) {
|
||||
// pm2环境下要接入clusterAdapter
|
||||
// https://socket.io/zh-CN/docs/v4/pm2/
|
||||
io.adapter(createAdapter());
|
||||
|
|
|
|||
Loading…
Reference in New Issue