In some cases, the servers do not allow obtaining some headers, in this case, the Authentication header.
One option is to contact your hosting provider to try to configure the server to accept these headers, or to edit the application code to use other allowed headers.
In this second case, the following actions must be carried out:
- Create the XAuthorizationHeader.php file in this directory:
app/Http/Middleware/XAuthorizationHeader.php
- Put the following content in the file (We have attached the file, which you can download at the end of this page):
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Closure;
class XAuthorizationHeader
{
public function handle($request, Closure $next)
{
if ($auth = $request->header('X-Authorization')) {
$request->headers->set('Authorization', $auth);
}
return $next($request);
}
} - The file should look like this:
- Then edit the Kernel.php file in this directory:
app/Http/Kernel.php
- And add the following line inside the $middleware array:
\App\Http\Middleware\XAuthorizationHeader::class,
- The file should look something like this:
- Then we have to edit this file:
resources/js/plugins/axios.js
- And replace the variable "Authorization" by "X-Authorization", there are two places:
- And here:
- After this we have to recompile the javascript files:
- We have to execute the following commands:
yarn install
yarn run prod - The second command can take up to 2 minutes to run, and the output should look something like this:
- After that, you can upload the files back to the server and reinstall the script.
This is a somewhat complex process, so if you have this problem we can do it for you, contact us and we will indicate the deadline, to do this we cost 5EUR.