config.default.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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://127.0.0.1/example',
  44. options: {},
  45. };
  46. // 异常捕获
  47. config.middleware = [ 'errorHandler' ];
  48. config.errorHandler = {
  49. match: '/api',
  50. };
  51. return {
  52. ...config,
  53. ...userConfig,
  54. };
  55. };