config.default.js
3.2 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* eslint valid-jsdoc: "off" */
"use strict";
const path = require("path");
/**
* @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 + "_1642067379356_9612";
// add your middleware config here
config.middleware = [];
// add your user config here
const userConfig = {
// myAppName: 'egg',
};
const view = {
root: path.join(appInfo.baseDir, "app/public"),
defaultViewEngine: "nunjucks",
mapping: {
".html": "nunjucks",
},
};
config.cluster = {
listen: {
path: "",
port: 8012,
hostname: "0.0.0.0",
},
};
config.restful = {
tokenUrl: "/uaa/v1/auth/tokens",
tokenMethod: "POST",
scope: "global_access:tenant_admin",
// host: 'http://118.178.181.180',
host: "http://47.110.250.177",
// host: 'http://47.110.158.110',
// host:'http://120.27.220.60',
// host: 'http://39.104.52.206',
// host: 'http://47.99.189.12',
ossUrl: "http://47.110.250.177:20000",
version: "/v1",
// host: '47.110.158.110',
// host: '120.27.220.60',
// host: '39.104.52.206',
port: 20000,
};
config.static = {
prefix: "/",
dir: path.join(appInfo.baseDir, "app/public"),
dynamic: true, //是否緩存靜態資源
preload: false, //啓動項目開啓緩存
maxAge: 0, //緩存時間 開發建議設0 跳坑
buffer: false, //是否緩存到内存 默認prod 緩存
};
const security = {
csrf: {
xframe: {
enable: false,
},
// heaederName:'cookie',
type: "ctoken", // can be ctoken, referer, all or any, default to ctoken
useSession: false, // if useSession set to true, the secret will keep in session instead of cookie
ignoreJSON: false, // skip check JSON requests if ignoreJSON set to true
cookieName: "csrfToken", // csrf token's cookie name
sessionName: "csrfToken", // csrf token's session name
headerName: "x-csrf-token", // request csrf token's name in header
bodyName: "_csrf", // request csrf token's name in body
queryName: "_csrf", // request csrf token's name in query
refererWhiteList: [], // referer white list
// queryName: '_csrf', // 通过 query 传递 CSRF token 的默认字段为 _csrf
// bodyName: '_csrf', // 通过 body 传递 CSRF token 的默认字段为 _csrf
ignore: (ctx) => {
if (
ctx.request.url.indexOf("/api") != -1 ||
ctx.request.url.indexOf("/doLogin") != -1
) {
return true;
}
return false;
},
},
};
config.connectHistoryApiFallback = {
whiteList: ["/api", "/passport", "/__webpack_hmr"],
};
config.logger = {
consoleLevel: "DEBUG",
// dir:'/root/logs/eggjs'
};
config.passportLocal = {
usernameField: 'username',
passwordField: 'password',
};
//redis config
const redis = {
client: {
host: "127.0.0.1",
port: "6379",
password: "",
db: "1",
},
agent: true,
};
return {
...config,
...userConfig,
security,
redis,
view,
};
};