万恶的Authorization问题;apache+小皮+tp6+vue3项目

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type,token,X-User-ID,Authorization"

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

跨域问题可以在.htaccess内修改

Header always set Access-Control-Allow-Origin “*”
Header always set Access-Control-Allow-Methods “GET, POST, OPTIONS”
Header always set Access-Control-Allow-Headers “Content-Type,token,X-User-ID,Authorization”

本地出现Authorization问题

win+小皮+apache 的环境下,前端发送了Authorization但是php接收不到。最后发现在tp6public下的.htaccess文件内增加配置:SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0

你可能感兴趣的:(apache)