I have an application in Laravel deployed on the server. When I try to call POST in Postman:
http://api.mydomain.com/api/auth/signin
I get the error 404 not found.
In file RouteServiceProvider I commented section for web:
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
/*
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
*/
});
}
When I had uncommented section for web and send GETfrom Postman but without any suffix, only domain: api.mydomain.com/ it worked.
Now I commented web and have only API section and any request to API method doesn't work.
My controller:
class JwtAuthController extends Controller
{
//
public function __construct() {
$this->middleware('auth:api', ['except' => ['login', 'register']]);
}
/**
* Get a JWT via given credentials.
*/
public function login(Request $request){
...
}
In api.php file:
Route::group([
'middleware' => 'api',
'prefix' => 'auth'
], function ($router) {
Route::post('/signin', [JwtAuthController::class, 'login']);
}
Result for php artisan route:list:
| App\Http\Middleware\Authenticate:api |
|
| POST
| api/auth/signin
| generated::1YOyMAVvTTnBZtym
| App\Http\Controllers\JwtAuthController@login
| api
On my local machine, it works, but when I deploy it on the server it won't work.