I'm having trouble retrieving the Authorization Header sent by Angular to Wamp Apache PHP.
Here is a snapshot of my chrome dev tools:
After a lot of research I was able to get the $_SERVER["HTTP_AUTHORIZATION"] variable to appear in PHP by adding any of those to the .htaccess file:
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
The following variations didn't work for me (PS: they may be viable for other people):
CGIPassAuth On
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
My issue is that the Header is now present in PHP but EMPTY .
An example of API endpoint being use
I think you should try $_SERVER['Authorization']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.