thinkphp6跨域问题

 问题:

Access to XMLHttpRequest at 'xxxxx.xxx' from origin 'null' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'xxxxx.xxx' that is not equal to the supplied origin.

 thinkphp6跨域问题

 

 

 

 解决:

在app目录下找到middeware.php加入以下未注释的代码

<?php
// 全局中间件定义文件
return [
    // 跨域请求支持
    \think\middleware\AllowCrossDomain::class,
    // 全局请求缓存
    // \think\middleware\CheckRequestCache::class,
    // 多语言加载
    // \think\middleware\LoadLangPack::class,
    // Session初始化
    // \think\middleware\SessionInit::class
];

上一篇:关于httplib CORS


下一篇:Access-Control-Allow-Origin 跨域设置多域名