phpapachephp-builtin-server

can't configure apache correctly


I have been having some issues, i am using THIS oauth library and at first I thought it had an error on it since i could get my tokens correctly but when consuming the tokens i got a 401 error, after some experimentation i found out that it has something to do with apache. If I start the php server from a command line it does work correctly, so now I am in a point where I have no idea what can apache be doing to make the scripts malfunction.

I have XAMPP installed on a windows machine. (Apache/2.4.27 (Win32) OpenSSL/1.0.2l PHP/7.1.9)

I have the virtualhost configured in apache, like this.

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/slim3-simple-rest-skeleton-master/public"
    ServerName TestSite
</VirtualHost>

and my etc hosts file added the line 127.0.0.1 TestSite

with that configuration i am able to make a request to http://testsite/oauth/token and get my access token, so here everything works just fine.

but when i go to http://testsite/books i get a blank page with 401 unauthorized header.

in the other hand, if i go to my folder slim3-simple-rest-skeleton-master and run this php -S 0.0.0.0:8888 -t public/

i can get my token at http://localhost:8888/oauth/token just as before, and when i do a get to http://localhost:8888/books it works correctly.

I have been trying to figure out what is different but i have no luck, i printed in both scenarios a phpinfo and couldn't spot any significant differences, any idea on what could i look for?

what could i try to log to see what's happening differently?


Solution

  • The problem was on apache deleting the Header authorization, by adding

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

    makes apache add the header and works correctly.