title: JWT The token could not be parsed from the request only on live site
body: <p>I have built a custom API using PHP (version 7.0), specifically the Laravel framework (version 5.5.40) that uses the tymon/jwt-auth (version 1.0.0-rc.2) package for user authorization. Many of my controller functions use this line to get the currect user's credentials:</p>
  
  <pre><code>$user = JWTAuth::parseToken()-&gt;authenticate();
  </code></pre>
  
  <p>I use Postman to test my api.</p>
  
  <p>When I make api calls in my local environment, the authorization passes normally and returns the expected data.
  When I make api calls to my live site API (hosted in my apache server), I get this error:</p>
  
  <p><em>The token could not be parsed from the request</em></p>
  
  <p>Since this error only occurs on my live API, I speculated that there is a problem with my API's .htaccess file (which is by the way recognized normally by the application, I did some debugging and checked my apache error_log to make sure changes to my API's .htaccess are recognized).
  I tried adding these lines (and different variations of these lines as I encountered multiple suggestions while researching):</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTP:Authorization} .+
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  </code></pre>
  
  <p>but still the error persists.
  I tried adding this code:</p>
  
  <pre><code>var_dump($_SERVER);
  </code></pre>
  
  <p>prior to the:</p>
  
  <pre><code>$user = JWTAuth::parseToken()-&gt;authenticate();
  </code></pre>
  
  <p>and I noticed that on my live API these elements are missing from the $_SERVER array:
  <strong>REDIRECT_HTTP_AUTHORIZATION, HTTP_AUTHORIZATION</strong></p>
  
  <p>Wasn't the above .htaccess code meant to add these manually?</p>
  
  <p>These are my Response Headers as seen in Chrome DevTools:</p>
  
  <p><strong>Access-Control-Allow-Origin:</strong> http:/example.gr</p>
  
  <p><strong>Cache-Control:</strong> no-cache, private</p>
  
  <p><strong>Connection:</strong> close</p>
  
  <p><strong>Content-Encoding:</strong> gzip</p>
  
  <p><strong>Content-Type:</strong> application/json</p>
  
  <p><strong>Date:</strong> Tue, 14 May 2019 11:33:10 GMT</p>
  
  <p><strong>Server:</strong> Apache</p>
  
  <p><strong>Transfer-Encoding:</strong> chunked</p>
  
  <p><strong>Vary:</strong> Origin,Accept-Encoding</p>
  
  <p><strong>X-RateLimit-Limit:</strong> 60</p>
  
  <p><strong>X-RateLimit-Remaining:</strong> 59</p>
  
  <p>And these are my Request Headers (provisional headers shown):</p>
  
  <p><strong>Accept:</strong> application/json, text/plain, <em>/</em></p>
  
  <p><strong>Authorization:</strong> Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkudjIucmVzY2FwZXIuaG9uZXN0cGFydG5lcnMuZ3JcL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE1NTc4MzM1ODksImV4cCI6MTY0NDIzMzU4OSwibmJmIjoxNTU3ODMzNTg5LCJqdGkiOiJweDRjNDlOckFQbGMyM21OIiwic3ViIjo1LCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.YWPhPDeNrB4TI1gdhBYylrmIAs1-r1-K2M2eKyO89KY</p>
  
  <p><strong>Origin:</strong> <a href="http://example.gr" rel="nofollow noreferrer">http://example.gr</a></p>
  
  <p><strong>Referer:</strong> <a href="http://example/summary" rel="nofollow noreferrer">http://example/summary</a></p>
  
  <p><strong>User-Agent:</strong> Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36</p>
  
  <p>EDIT:
  This is the virtual host configuration of the production server for this specific domain as found in the httpd.conf file:</p>
  
  <pre><code>&lt;VirtualHost |example-ip|:80&gt;
    ServerName api.example.gr
      ServerAlias www.api.example.gr
    DocumentRoot /home/example/public_html/api/public
    ServerAdmin webmaster@api.example.gr
    UseCanonicalName Off
  
    ## User example # Needed for Cpanel::ApacheConf
    &lt;IfModule userdir_module&gt;
      &lt;IfModule !mpm_itk.c&gt;
        &lt;IfModule !ruid2_module&gt;
          &lt;IfModule !mod_passenger.c&gt;
            UserDir enabled example
          &lt;/IfModule&gt;
        &lt;/IfModule&gt;
      &lt;/IfModule&gt;
    &lt;/IfModule&gt;
  
    # Enable backwards compatible Server Side Include expression parser for Apache versions &gt;= 2.4.
    # To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
    # the user's .htaccess file.  For more information, please read:
    #    http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
    &lt;IfModule include_module&gt;
      &lt;Directory "/home/example/public_html/api/public"&gt;
        SSILegacyExprParser On
      &lt;/Directory&gt;
    &lt;/IfModule&gt;
  
  
  
    &lt;IfModule suphp_module&gt;
      suPHP_UserGroup example example
    &lt;/IfModule&gt;
    &lt;IfModule suexec_module&gt;
      &lt;IfModule !mod_ruid2.c&gt;
        SuexecUserGroup example example
      &lt;/IfModule&gt;
    &lt;/IfModule&gt;
    &lt;IfModule ruid2_module&gt;
      RMode config
      RUidGid example example
    &lt;/IfModule&gt;
    &lt;IfModule mpm_itk.c&gt;
      # For more information on MPM ITK, please read:
      #   http://mpm-itk.sesse.net/
      AssignUserID example example
    &lt;/IfModule&gt;
    &lt;IfModule mod_passenger.c&gt;
      PassengerUser example
      PassengerGroup example
    &lt;/IfModule&gt;
  
    &lt;IfModule alias_module&gt;
      ScriptAlias /cgi-bin/ /home/example/public_html/api/public/cgi-bin/
    &lt;/IfModule&gt;
  
  
  
  
  
    # To customize this VirtualHost use an include file at the following location
    # Include "/etc/apache2/conf.d/userdata/std/2_4/example/api.example.gr/*.conf"
  &lt;/VirtualHost&gt;
  &lt;VirtualHost 1|example-ip|:443&gt;
    ServerName api.example.gr
    ServerAlias www.api.example.gr
    DocumentRoot /home/example/public_html/api/public
    ServerAdmin webmaster@api.example.gr
    UseCanonicalName Off
  
    ## User example # Needed for Cpanel::ApacheConf
    &lt;IfModule userdir_module&gt;
      &lt;IfModule !mpm_itk.c&gt;
        &lt;IfModule !ruid2_module&gt;
          &lt;IfModule !mod_passenger.c&gt;
            UserDir enabled example
          &lt;/IfModule&gt;
        &lt;/IfModule&gt;
      &lt;/IfModule&gt;
    &lt;/IfModule&gt;
  
    # Enable backwards compatible Server Side Include expression parser for Apache versions &gt;= 2.4.
    # To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
    # the user's .htaccess file.  For more information, please read:
    #    http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
    &lt;IfModule mod_include.c&gt;
      &lt;Directory "/home/example/public_html/api/public"&gt;
        SSILegacyExprParser On
      &lt;/Directory&gt;
    &lt;/IfModule&gt;
  
  
    &lt;Proxymatch ^https?://127\.0\.0\.1:(2082|2083|2077|2078|2079|2080|2086|2087|2095|2096)/&gt;
         &lt;IfModule security2_module&gt;
            SecRuleEngine Off
         &lt;/IfModule&gt;
    &lt;/Proxymatch&gt;
  
    &lt;IfModule mod_suphp.c&gt;
      suPHP_UserGroup example example
    &lt;/IfModule&gt;
    &lt;IfModule suexec_module&gt;
      &lt;IfModule !mod_ruid2.c&gt;
        SuexecUserGroup example example
      &lt;/IfModule&gt;
    &lt;/IfModule&gt;
    &lt;IfModule ruid2_module&gt;
      RMode config
      RUidGid example example
    &lt;/IfModule&gt;
    &lt;IfModule mpm_itk.c&gt;
      # For more information on MPM ITK, please read:
      #   http://mpm-itk.sesse.net/
      AssignUserID example example
    &lt;/IfModule&gt;
    &lt;IfModule mod_passenger.c&gt;
      PassengerUser example
      PassengerGroup example
    &lt;/IfModule&gt;
  
    &lt;IfModule alias_module&gt;
      ScriptAlias /cgi-bin/ /home/example/public_html/api/public/cgi-bin/
    &lt;/IfModule&gt;
    &lt;IfModule ssl_module&gt;
      SSLEngine on
  
      SSLCertificateFile /var/cpanel/ssl/apache_tls/api.example.gr/combined
  
      SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
      &lt;Directory "/home/example/public_html/api/public/cgi-bin"&gt;
        SSLOptions +StdEnvVars
      &lt;/Directory&gt;
    &lt;/IfModule&gt;
  
  
  
  
    # To customize this VirtualHost use an include file at the following location
    # Include "/etc/apache2/conf.d/userdata/ssl/2_4/example/api.example.gr/*.conf"
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>It should be noted that my actual API's ip and domain haven been replaced with example ones:</p>
  
  <p><strong>front url:</strong> <a href="http://example.gr" rel="nofollow noreferrer">http://example.gr</a></p>
  
  <p><strong>api url:</strong> <a href="http://api.example.gr" rel="nofollow noreferrer">http://api.example.gr</a></p>