Home > Mobile >  Laravel auth middleware redirects to localhost even after changing the APP_URL
Laravel auth middleware redirects to localhost even after changing the APP_URL

Time:03-27

I have deployed my Laravel 8 application on live server and have set up the reverse proxy successfully to access the laravel app from a url like example.com/app/my-app.

Now the problem is, as I have used auth middleware which requests user to log in before he/she can access the app, opening example.com/app/my-app redirects to localhost:8000/login

Which is wrong as it is supposed to redirect to example.com/app/my-app/login

I have:

  • set the 'url' => "example.com/app/my-app" in config/app.php
  • ran php artisan optimize:clear
  • ran php artisan cache:clear
  • And also stopped the app and ran php artisan serve again

Can you please help me? Am I missing something?

CodePudding user response:

Remove the file inside the bootstrap/cache directory.Then run the following command :

php artisan cache: clear
php artisan config: clear
php artisan view: clear
php artisan route: clear
php artisan config: cache
php artisan optimize

Hope this will fixed your problems.

CodePudding user response:

You can use in web.php, if user not auth redirect '/' => '/login'

    Route::group(['middleware' => 'guest'], function () {
        // Redirect '/' => '/login'
        Route::redirect('/', '/login');
        // Auth routes
        Auth::routes();
    });
  • Related