i einrichten frisch L5.2 und meine Route Dateien nach Änderungen sieht wie folgt aus:Laravel5.2 Unerwünschte VerifyCsrfToken
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function() {
return view('welcome');
});
Route::group(['middleware' =>'api', 'prefix' => '/api/v1'], function() {
Route::post('/api/v1/login', 'Api\V1\Auth\[email protected]');
});
Wenn ich zu Postbote gehen und POST machen: http://kumarajiva.dev/api/v1/login ich: TokenMismatchException in VerifyCsrfToken.php line 67
Aber meine Kernel-Datei sieht so aus:
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
];
Ich ändere nichts. Route 'Login' ist in 'api' Middelware-Gruppe (nicht 'Web', wo ist VerifyCsrfToken), aber überraschend bekomme ich über Fehler. Also frage ich mich - wtf? Wie es funktioniert? Wird die Middlewaregruppe 'web' immer ausgeführt (für jede Anfrage)?
Ja, Sie haben Recht, ich laufe 'php artisan route: list' und alle meine Routen haben 'Web' Middelware. Es ist sehr kontraintuitiv ... danke U für deine Antwort. –
Nachdem ich "middleware" => "web" aus der Funktion "RouteServiceProvider @ mapWebRoutes" entfernt habe, funktioniert es :) was ich mit 'php artisan route: list' sehe –