Middleware works on localhost but not on apache2 VM server
It would seem your routes are cached. Since this is on your server (host) you should recache the routes:
php artisan route:cache
You should make this part of your deployment process as well as recaching the configuration (php artisan config:cache
), running composer install
, running migrations (php artisan migrate
), etc.
If this isn't really a live site and you are still in development you could also not cache the routes at all, then you wouldn't need to be recaching them every time you make changes to your routes. You could clear the cache with php artisan route:clear
. This is how you would run locally, without the routes cached. Just make sure when you are deploying your live site that caching the routes is part of your process.