| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /* eslint valid-jsdoc: "off" */
- 'use strict';
- const path = require('path');
- /**
- * @param {Egg.EggAppInfo} appInfo app info
- */
- module.exports = appInfo => {
- /**
- * built-in config
- * @type {Egg.EggAppConfig}
- **/
- const config = {};
- // use for cookie sign key, should change to your own and keep security
- config.keys = appInfo.name + '_1552879336505_7432';
- // add your middleware config here
- config.middleware = [];
- // add your user config here
- const userConfig = {
- // myAppName: 'egg',
- };
- config.cluster = {
- listen: {
- port: 7068,
- hostname: '0.0.0.0',
- // path: '/var/run/egg.sock',
- },
- };
- // jwt插件配置(盐)
- config.jwt = {
- secret: 'jcgame88',
- };
- /* 跨域插件配置-start */
- config.security = {
- xframe: {
- enable: false,
- },
- ignore: '/api',
- // 跨域允许的域名列表-配置
- domainWhiteList: [
- '*',
- // 'http://127.0.0.1:8080'
- ],
- methodnoallow: { enable: false },
- // 安全配置(很重要)
- csrf: {
- enable: false,
- ignoreJSON: true, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
- },
- };
- // 允许的跨域请求类型(GET,POST)
- config.cors = {
- origin: '*',
- // allowMethods: 'GET,POST',
- allowMethods: 'GET,POST,HEAD,PUT,OPTIONS,DELETE,PATCH',
- };
- /* 跨域插件配置-end */
- // 校验插件配置(支持 parameter的所有配置项)
- config.validate = {
- // convert: false,
- // validateRoot: false,
- };
- // 获取真实ip
- config.maxProxyCount = 2;
-
- config.view = {
- root: [path.join(appInfo.baseDir, 'app/view')].join(','),
- mapping: {
- '.ejs': 'ejs',
- },
- };
- config.static = {
- // 静态化访问前缀,如:`http://127.0.0.1:7001/static/images/logo.png`
- prefix: '/',
- dir: [path.join(appInfo.baseDir, 'app/public')], // `String` or `Array:[dir1, dir2, ...]` 静态化目录,可以设置多个静态化目录
- dynamic: true, // 如果当前访问的静态资源没有缓存,则缓存静态文件,和`preload`配合使用;
- preload: false,
- maxAge: 31536000, // in prod env, 0 in other envs
- buffer: true, // in prod env, false in other envs
- };
- config.ejs = {};
- return {
- ...config,
- ...userConfig,
- };
- };
|