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');

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.