Can you try going without caching
php artisan optimize:clear
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a project the backend is on Laravel, the frontend is on Vue 3.
The project works perfectly on local (valet), but when I deploy it to aws (using forge) the problems started appearing.
First when using in web.php:
Route::get('/{any}', function () {
return view('app'); //Just as context is where I put the <router-view> tag
})->where('any', '.*');
I called, in postman, the POST /api/login that I have defined on the api.php file, the response (on server) was the HTML of the app view.
Then searching the web and trying some different things. I modified the web.php from what i previously got to this:
Route::get('/{any}', function () {
return view('app');
})->where('any', '^(?!api).*$')->where('any', '^((?!storage).)*$');
And again I tried calling the POST /api/login route via postman (on server), and then I got the following response:
{
"message": "The GET method is not supported for this route. Supported methods: POST."
}
My forge deploy script looks like this:
cd /home/forge/proyect_name
git pull origin $FORGE_SITE_BRANCH
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
if [ -f artisan ]; then
$FORGE_PHP artisan migrate --force
$FORGE_PHP artisan cache:clear
$FORGE_PHP artisan route:cache
$FORGE_PHP artisan config:cache
$FORGE_PHP artisan view:clear
$FORGE_COMPOSER dump-autoload
fi
Just to add my RouteServiceProvider is the same as the fresh laravel instance.
It's very hard for me to debug since this is only happening on the server.
Has anyone got this issue previously and have any idea how to solve it?
Please or to participate in this conversation.