Get Header AUTHORIZATION value

Hi @Teodor ,

I have prepared an API in Wappler and I am sending a query to this API with an ‘AUTHORIZATION’ header. My goal is to send the token information within the ‘AUTHORIZATION’ header. I am doing this with Postman and I can see that the information is present in the header. However, when I try to retrieve the ‘AUTHORIZATION’ value from the header using ‘$_SERVER.HTTP_AUTHORIZATION’, the returned value is null. Do you have any idea about this issue? Or is there any other method to read the value from the header?

Ekran Resmi 2023-02-15 15.00.43

What is the server you are using (NodeJS, PHP Apache or Nginx)?

apache - Authorization header missing in PHP POST request - Stack Overflow

Yes @patrick , I have read this article before, but I didn’t make any corrections because I was worried that a Wappler update that affects htaccess would cause the issue to recur. Also, I noticed something while searching the internet, which was that if I chose a different word instead of ‘authorization’, I could see it in $_SERVER. Therefore, I added a prefix to the word ‘authorization’ and I can read the data I send in this way.

However, to solve the problem permanently, I think it may be necessary to include a solution similar to what was shown on Stack Overflow in Wappler

Server Type : PHP Apache

You can edit the .htaccess, Wappler will only update the part bewteen ## Wappler routing and ## End Wappler routing and not touch any additional rules you add.

1 Like

hi Patrick
i have the same problem here
but,what exactly i have to edit in htaccess file to solve it ?

To keep the authorization header add the following to the htaccess.

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

You can find more solutions in the comments of PHP: HTTP authentication with PHP - Manual

1 Like