0

I'm trying to use Google Dialogflow to catch what the user says to a Google Home, send it to my server and then send a dynamic response. Dialogflow sends a POST request to my server which has Laravel.

I only use Laravel in API mode so I'd like my route to be in api.php file, but the request is always return a 404 error, while it's working when I put my route in web.php file.

This is working in web.php, not in api.php

Route::post('/api', 'ApiController@sendResponse');
Skery
  • 57
  • 1
  • 8

1 Answers1

1

if you put the route in the api.php it has a prefix of api

Here is an example. if you look into the RouteServiceProvider

 /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }

So your route for the API will be yourdomain.com/api/api

FULL STACK DEV
  • 15,207
  • 5
  • 46
  • 66