config.default.js 1.47 KB
/* eslint valid-jsdoc: "off" */

'use strict';

const { mysql } = require("../config/confg.dev");

/**
 * @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 + '_1646015306357_8919';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  // 跨域配置
  config.security = {
    csrf: {
      enable: false
    },
    domainWhiteList: ['*']
  };

  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
  };

  config.mysql = mysql;

  // 登录鉴权
  config.jwt = {
    secret: 'glsx-config-center',
  };

  // // 错误监听
  // config.onerror = {
  //   html(err, ctx) {
  //     // html hander
  //     ctx.body = { message: err.message, code: '401', data: '' };
  //     //ctx.status = 401;
  //   },
  //   json(err, ctx) {
  //     //ctx.body = { message: err };
  //     ctx.body = { message: err.message, code: '402', data: '' };
  //     //ctx.status = 402;
  //   },
  //   jsonp(err, ctx) {
  //     // 一般来说,不需要特殊针对 jsonp 进行错误定义,jsonp 的错误处理会自动调用 json 错误处理,并包装成 jsonp 的响应格式
  //   },
  // }

  return {
    ...config,
    ...userConfig,
  };
};