config.default.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* eslint valid-jsdoc: "off" */
  2. 'use strict';
  3. /**
  4. * @param {Egg.EggAppInfo} appInfo app info
  5. */
  6. module.exports = appInfo => {
  7. /**
  8. * built-in config
  9. * @type {Egg.EggAppConfig}
  10. **/
  11. const config = exports = {};
  12. // use for cookie sign key, should change to your own and keep security
  13. config.keys = appInfo.name + '_1618984590142_9986';
  14. // add your middleware config here
  15. config.middleware = [];
  16. // 关闭安全防范
  17. config.security = {
  18. csrf: {
  19. enable: false,
  20. ignoreJSON: true,
  21. },
  22. };
  23. config.cors = {
  24. origin: '*',
  25. allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
  26. };
  27. // add your user config here
  28. const userConfig = {
  29. // myAppName: 'egg',
  30. };
  31. // 解除文件上传大小限制
  32. config.bodyParser = {
  33. jsonLimit: '100mb',
  34. formLimit: '100mb',
  35. };
  36. // jwt密钥
  37. config.jwt = {
  38. secret: '123456',
  39. };
  40. config.userSecret = '123456';
  41. // 数据库配置
  42. config.mongoose = {
  43. url: 'mongodb://172.17.116.7:27018/example',
  44. options: {
  45. user: 'root',
  46. pass: 'cms@cc-lotus',
  47. authSource: 'admin',
  48. useNewUrlParser: true,
  49. useCreateIndex: true,
  50. useUnifiedTopology: true,
  51. },
  52. };
  53. // 异常捕获
  54. config.middleware = [ 'errorHandler' ];
  55. config.errorHandler = {
  56. match: '/api',
  57. };
  58. return {
  59. ...config,
  60. ...userConfig,
  61. };
  62. };