Skip to content

Commit b8c3bd6

Browse files
committed
feat: use egg-cors && allow orgin *
1 parent b429ef2 commit b8c3bd6

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Diff for: config/config.default.js

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ module.exports = appInfo => {
2727
},
2828
};
2929

30+
config.cors = {
31+
origin: '*', // TODO: use security domainWhiteList in production
32+
};
33+
3034
config.smsVerify = {
3135
ttl: 10, // 验证码有效期(分钟)
3236
mock: env.SMS_MOCK, // 如果设置了mock,就不会真正去发短信

Diff for: config/plugin.js

+5
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ exports.passportWechat = {
2727
enable: true,
2828
path: path.join(__dirname, '../lib/plugin/egg-passport-wechat'),
2929
};
30+
31+
exports.cors = {
32+
enable: true,
33+
package: 'egg-cors',
34+
};

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dependencies": {
77
"bluebird": "^3.5.1",
88
"egg": "^2.2.1",
9+
"egg-cors": "^2.0.0",
910
"egg-passport": "^2.0.1",
1011
"egg-scripts": "^2.5.0",
1112
"egg-sequelize": "^3.1.4",

0 commit comments

Comments
 (0)