发布于: 2021-12-3最后更新: 2024-12-31字数 108阅读时长 1 分钟

type
status
date
slug
summary
tags
category
icon
password
axios添加自定义请求头 在axios拦截器中, headers['XXX'] = 'XX' 配置后,thinkphp 返回跨域.需要对thinkphp中间件进行重新设置
主要配置在tp
  • 复制 vendor\topthink\framework\src\think\middleware\AllowCrossDomain.php文件到app\common 下
  • 追加vue传过来的自定义请求头到$header数组内Access-Control-Allow-Headers

plain

protected $header = [ 'Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With, XXX', ];
Plain text
  • app\middleware.php引入

plain

<?php // 全局中间件定义文件 return [ \\app\\common\\middleware\\AllowCrossDomain::class ];
Plain text

Loading...
sublime text4配置vue开发环境

sublime text4配置vue开发环境


minio+thumbor

minio+thumbor