Error http 419 Laravel-Cors?

Asked

Viewed 441 times

1

To fix Cors failure in the Laravel api I used the package Laravel Cors and followed everything that was reported in readme, but now it is returning an error to me when making a request http post

Error:

POST http://127.0.0.1:8000/hqi/lecture 419 (Unknown status)

Controller concerning the request:

public function store(Request $request)
{
    $palestras_divulgacao = new palestras_divulgacao;
    $palestras_divulgacao->fill($request->all());
    $palestras_divulgacao->save();
    return response()
            ->json($palestras_divulgacao, 201);
}

Calling for http post Angular on the client side:

public registrarPalestra(p: palestras): Observable<number> {
    let headers: Headers = new Headers()
    headers.append('Content-type', 'aplication\json')

    return this.http.post(
      `${URL_API}palestra`,
      JSON.stringify(p),
      new RequestOptions({headers: headers})
    ).pipe(map(response => response.json().id));
}

1 answer

2


Must be the part of protection CSRF that must be configured in the file app\Http\Middleware\VerifyCsrfToken.php, within the configuration $except the route hqi/* to release this verification route, example:

<?php namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{        
    protected $except = [
        'hqi/*',
    ];
}

References:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.