My web routes are working, however I cannot POST to my api routes, I receive MethodNotAllowedHttpException. I think this is a csrf token problem as GET works, but I can't figure out how to fix it. I am using Postman to simulate api requests.
auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'devices',
],
],
RouteServiceProvider.php
protected function mapApiRoutes()
{
Route::middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
routes/api.php
Route::post('api', ['uses' => 'DeviceController@api']);
kernel.php
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' => [
'throttle:60,1',
'auth:api',
'bindings',
],
];
This is an upgrade from an older version of Laravel that was working, I upgraded by installing a fresh copy of Laravel 5.4 then copied over my code, changing it as needed.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l001qg
via IFTTT
Aucun commentaire:
Enregistrer un commentaire