Skip to content

Api group 404 not found #1768

Description

@mk-fangkuai
Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 8.12
Package version 3.0.5
PHP version 8.0.1

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 | | |

+------+----------+-------------+-------------+--------------------------------------------------+-----------+------------+----------+------------+

Activity

  1. specialtactics commented on Apr 30, 2021

    @specialtactics
    Member

    Hey, can you please post your http Kernel.php file?

  2. ALTELMA commented on Jul 14, 2021

    @ALTELMA

    @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?

  3. ALTELMA commented on Jul 14, 2021

    @ALTELMA

    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.

  4. bm2ilabs commented on Aug 24, 2021

    @bm2ilabs

    Thanks @fredroo indeed it was the issue

  5. specialtactics commented on Sep 10, 2021

    @specialtactics
    Member

    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 😛

  6. RajuPuthen commented on Oct 13, 2021

    @RajuPuthen

    @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,
    ];

  7. specialtactics commented on Jan 26, 2022

    @specialtactics
    Member

    @RajuPuthen plz post your HTTP kernel file and env file and what is the URL you are using to access them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions