'Laravel passport auth token not working after moving to different server

I have created this small app using laravel + vue js 2 years ago. It has been working fine till now but the server guys moved it to different server and suddenly I have started getting "unauthenticated" error on all pages.

The login form works and it generates the personal access token nicely, but when I use that personal access token anywhere on this portal like this "Bearer MY_PERSONAL_ACCESS_TOKEN", it doesn't work.

Is there any additional step I have to do after moving the files to different server? The URL are all same, its just the server is changed. I have also tried running php artisan passport:install but it doesn't fix the issue. I have hundreds of user accounts stored on this DB and now they are unable to use any features.

Any idea how I sort this issue?



Solution 1:[1]

Have you tried typing this into the console?

php artisan key:generate

Solution 2:[2]

Add these lines in your .htaccess on your server files.

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hasan ABLAK
Solution 2 Karl Hill