eggjs post请求时报invalid csrf token

eggjs yekong 184℃
invalid csrf token

如果是开发模式的话,可以暂时关闭,关闭方法
找到config/config.default.js

添加csrf配置,关闭csrf

  // csrf
  config.security = {
    csrf: {
      enable: false,
    },
  };
/* eslint valid-jsdoc: "off" */

'use strict';

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

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

  // csrf
  config.security = {
    csrf: {
      enable: false,
    },
  };
  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

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

喜欢 (0)