0
votes

I am getting 404 error on my live server when using Laravel api routes. On my local, everything works fine. It is just a simple post request to register a user. Iv also tried GET request and received same result. These routes are not wrapped in any middleware. Iv setup the api as per laravel instruction from https://laravel.com/docs/5.7/passport#installation

I have tried php artisan cache:clear, restarting nginx, hard refresh browser but none of those work.

Chrome Screen shot

php artisan route:list

My api.php

<?php

use Illuminate\Support\Facades\Route;

Route::get('test', 'UserAuthController@test');
Route::post('register', 'UserAuthController@registerUser');
Route::post('login', 'UserAuthController@loginUser');
1

1 Answers

0
votes

After changing the location in sites-available/default to

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

instead of the default one which was a 404 everything worked.

I would still like to know why. Why would this query_string block my laravel app from accessing the routes in api.php?

There was no instruction about how important this line is. It just seemed like a line to redirect to index.php when a route does not exist.