config.default.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. config.multipart = {
  37. fileSize: '50mb',
  38. mode: 'stream',
  39. fileExtensions: [ '.xls', '.png', '.jpg', '.doc', '.xlsx', '.docx', '.rar', '.zip', '.7z', '.pdf' ], // 扩展几种上传的文件格式
  40. };
  41. // jwt密钥
  42. config.jwt = {
  43. secret: '123456',
  44. };
  45. config.userSecret = '123456';
  46. // 数据库配置
  47. // config.mongoose = {
  48. // url: 'mongodb://172.17.116.7:27018/example',
  49. // options: {
  50. // user: 'root',
  51. // pass: 'cms@cc-lotus',
  52. // authSource: 'admin',
  53. // useNewUrlParser: true,
  54. // useCreateIndex: true,
  55. // useUnifiedTopology: true,
  56. // },
  57. // };
  58. config.mongoose = {
  59. url: 'mongodb://127.0.0.1:27017/example',
  60. options: {},
  61. };
  62. // 异常捕获
  63. config.middleware = [ 'errorHandler' ];
  64. config.errorHandler = {
  65. match: '/api',
  66. };
  67. return {
  68. ...config,
  69. ...userConfig,
  70. };
  71. };