tp6跨域中间件无效,入口文件写header允许跨域也无效,如何处理?

浏览:2873 发布日期:2020/05/10 分类:ThinkPHP6专区
API涉及到跨域,开启tp6跨域中间件: app/middleware.php<?php
// 全局中间件定义文件
return [
    // 跨域支持
    \think\middleware\AllowCrossDomain::class
];
跨域无效,在入口文件或者api接口方法写:header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods:GET, POST, PATCH, PUT, DELETE');
header('Access-Control-Allow-Headers:Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With');
都无效,这是怎么回事?
最佳答案
评论( 相关
后面还有条评论,点击查看>>