Open mk-fangkuai opened 3 years ago
same problem, api group return 404 after migration from laravel 5.8 to 6, dingo api 2.4.7 from 2.3.0
Hey, can you please post your http Kernel.php file?
In my case solve by domain in .env
@fredroo Do you mean API_DOMAIN, right? @specialtactics This problem cause sometimes. I really want to know for where to debug or checking first.
In my case when I using same configuration, but different environment, domain etc.
Domain is the one factor to made route always return 404, right?
Is it possible to share dingo API logic for routing?
@ALTELMA yes
Thanks for your suggestion @fredroo. My case depends on the configuration of the server, but it can end the problem as you mentioned. Normally I using Nginx for proxy and API_DOMAIN related to the internal proxy_pass such as order-service, payment-service. When I try to change to use Ingress Nginx Controller API_DOMAIN should replace by a real domain.
Hopefully, this helps someone fix your problem.
Thanks @fredroo indeed it was the issue
Hey @ALTELMA
Is it possible to share dingo API logic for routing?
Yes, this logic is in the code which is shared via this repository :stuck_out_tongue:
@specialtactics , I am also facing the same issue. I am getting 404 error for my API routes. Other routes are working fine.
"php artisan api:routes" command would list all API routes, but those returning 404. Any suggestion would be appreciated.
I am using below configuration values in my .env file
API_PREFIX= API_DOMAIN=localhost
My kernal.php file is below,
protected $middleware = [ //\Fruitcake\Cors\HandleCors::class, // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Fruitcake\Cors\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ];
protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ];
@RajuPuthen plz post your HTTP kernel file and env file and what is the URL you are using to access them.
1223/5000
Actual behavior
api.php
$api = app('Dingo\Api\Routing\Router');
$api->group(["version"=>"v1","namespace"=>"\App\Http\Controllers\Admin","prefix"=>"admin"], function ($api) {
$api->get("login","LoginController@login")->name("admin.login");
});
404 not found
sail@caca0a954c1f:/var/www/html$ php artisan api:routes
+------+----------+-------------+-------------+--------------------------------------------------+-----------+------------+----------+------------+
| Host | Method | URI | Name | Action | Protected | Version(s) | Scope(s) | Rate Limit |
+------+----------+-------------+-------------+--------------------------------------------------+-----------+------------+----------+------------+
| | GET|HEAD | admin/login | admin.login | App\Http\Controllers\Admin\LoginController@login | No | v1 | | |
+------+----------+-------------+-------------+--------------------------------------------------+-----------+------------+----------+------------+