Error http 419 laravel-cors?

1

To fix the crash of cors in api laravel I used the package Laravel Cors and followed everything I was informed in , but now it is returning an error when executing a request http post

Error:

  

POST link 419 (unknown status)

Controller for 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 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));
}
    
asked by anonymous 14.10.2018 / 18:47

1 answer

1

It should be the part of the CSRF protection that should be configured in the app\Http\Middleware\VerifyCsrfToken.php file, within the $except the route hqi/* to release this route from this check, example :

<?php namespace App\Http\Middleware;

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

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

References

14.10.2018 / 23:12