[英]Laravel CSRF protection exception now working
我的Laravel項目就在這個鏈接中
http://localhost/demo/public // laravel project
我有這個外部HTML表單
http://localhost/attendance
現在我想將表單中的數據發送到Laravel但是我收到了這個錯誤
419頁已過期
所以在我的laravel項目中,VerifyCsrfToken類我寫了這個
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'http://localhost/attendance'
];
}
但仍然有同樣的錯誤
419頁已過期
Laravel為你解決你的應用程序的baseUrl,沒有必要把完整的路徑,在你的情況下,中間件應該如下所示:
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'attendance/*'
];
}
一種解決方案是將數據作為GET請求而不是POST請求發送。
將工作放到網上后,您將面臨瀏覽器的跨站點保護。
要排除的URI
是接收請求的URI
,因此http://localhost/demo/public
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.