config.default.js
1.47 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
/* 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 = [];
// 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.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 的响应格式
// },
// }
return {
...config,
...userConfig,
};
};