config.default.js
2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* eslint valid-jsdoc: "off" */
'use strict';
const { mysql } = require('../config/confg.dev');
/**
* @param {Egg.EggAppInfo} appInfo app info
*/
module.exports = appInfo => {
/**
* built-in config
* @type {Egg.EggAppConfig}
**/
const config = exports = {};
// use for cookie sign key, should change to your own and keep security
// config.keys = appInfo.name + '_1646015306357_8919';
// add your middleware config here
// config.middleware = ["tokenHandler", "errorHandler"];
config.middleware = [ 'errorHandler' ];
// // 中间件执行匹配开启
// config.tokenHandler = {
// match(ctx) { // 只匹配指定路由,反之如果只忽略指定路由,可以用ignore
// //匹配不需要验证token的路由
// const url = ctx.request.url;
// if (url.startsWith("/login") || url.startsWith("/register")) {
// // ctx.logger.info('config.tokenHandler:','关闭token验证')
// return false;
// } else {
// // ctx.logger.info('config.tokenHandler:','开启token验证')
// return true; // 开启中间件,开启token验证
// }
// }
// };
// add your user config here
const userConfig = {
// myAppName: 'egg',
};
// 跨域配置
config.security = {
csrf: {
enable: false,
},
domainWhiteList: [ '*' ],
};
// config.cors = {
// origin: '*',
// allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
// };
// config.mysql = mysql;
config.sequelize = {
dialect: 'mysql', // support: mysql, mariadb, postgres, mssql
database: 'config_center',
host: '192.168.3.190',
port: 3306,
username: 'dev_user',
password: 'df234fl',
define: {
underscored: false,
freezeTableName: true,
timestamps: false,
},
};
// 登录鉴权
config.jwt = {
secret: 'glsx-config-center',
};
// 错误监听
// config.onerror = {
// html(err, ctx) {
// // html hander
// ctx.body = { message: err.message, code: '401', data: '' };
// //ctx.status = 401;
// },
// json(err, ctx) {
// //ctx.body = { message: err };
// ctx.body = { message: err.message, code: '402', data: '' };
// //ctx.status = 402;
// },
// jsonp(err, ctx) {
// // 一般来说,不需要特殊针对 jsonp 进行错误定义,jsonp 的错误处理会自动调用 json 错误处理,并包装成 jsonp 的响应格式
// },
// }
// ip访问
config.cluster = {
listen: {
// path: '',
// port: 7001,
hostname: '0.0.0.0',
},
};
return {
...config,
...userConfig,
};
};