久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Laravel 5 中,如何禁用特定路由的 VerifycsrfTok

In Laravel 5, How to disable VerifycsrfToken middleware for specific route?(在 Laravel 5 中,如何禁用特定路由的 VerifycsrfToken 中間件?)
本文介紹了在 Laravel 5 中,如何禁用特定路由的 VerifycsrfToken 中間件?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 Laravel 5 開發應用程序.我的應用程序與 VendHQ API 連接,我打算通過他們的 webhook 從 VendHQ 獲取一些數據.根據他們的文檔

I am using Laravel 5 for developing an app. My app is connected with VendHQ API and I am intended to get some data from VendHQ through their webhook. As per their Documentation

當一個事件發生并觸發一個 webhook 時,我們將發送一個 POST請求到您選擇的 URL.POST 請求將在UTF-8 字符集和 application/x-www-form-urlencoded 編碼.

When an event happens and triggers a webhook, we’ll send a POST request to a URL of your choosing. The POST request will be in the UTF-8 charset, and application/x-www-form-urlencoded encoding.

問題是,當他們嘗試向我的 Laravel 應用程序發送 POST 請求時,他們的發布請求中沒有添加 CSRF 令牌,并且 VerifyCsrfToken 中間件正在尋找令牌,最后它拋出一個 <代碼>TokenMismatchException.

The problem is, when they try to send a POST request to my Laravel app, no CSRF Token is added in their post request and VerifyCsrfToken middleware is looking for a token and finally it throws a TokenMismatchException.

我的問題是,如何在保持其他發布請求處于活動狀態的同時避免某些特定路由的默認 VerifyCsrfToken 中間件?

My question is, how can I avoid this default VerifyCsrfToken Middleware for some specific routes while keeping other post requests active?

推薦答案

Laravel 5 中所有路由默認開啟 CSRF,你可以通過修改 app/Http/Middleware/VerifyCsrfToken.php 為特定路由禁用它

CSRF is enabled by default on all Routes in Laravel 5, you can disable it for specific routes by modifying app/Http/Middleware/VerifyCsrfToken.php

//app/Http/Middleware/VerifyCsrfToken.php

//add an array of Routes to skip CSRF check
private $openRoutes = ['free/route', 'free/too'];

//modify this function
public function handle($request, Closure $next)
    {
        //add this condition 
    foreach($this->openRoutes as $route) {

      if ($request->is($route)) {
        return $next($request);
      }
    }

    return parent::handle($request, $next);
  }

來源

這篇關于在 Laravel 5 中,如何禁用特定路由的 VerifycsrfToken 中間件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數)
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內容必須是實現 __toString()、“boolean和“boolean的字符串或對象.移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 欧美国产精品一区二区 | 美女视频黄的免费 | 美女久久| 国产成人在线一区二区 | 成人精品一区亚洲午夜久久久 | 亚洲视频一区在线观看 | 欧美精品v国产精品v日韩精品 | 亚洲一区二区中文字幕 | 男女那个视频 | 一本色道久久综合亚洲精品高清 | 亚洲精品国产成人 | 国产国拍亚洲精品av | 国产良家自拍 | 一级黄色夫妻生活 | 99精品国自产在线 | 91精品国产91久久综合桃花 | 亚洲444kkkk在线观看最新 | 久久国产免费看 | 成人午夜视频在线观看 | 99免费在线| 精品亚洲永久免费精品 | 日本视频一区二区 | 91视频中文| 久草青青草 | 午夜网站视频 | 国产一区二区三区四区hd | 亚洲精品一区二区在线观看 | 激情 一区| 久久一区二区精品 | 成人久草 | 国产精品成人一区二区 | 精品三区| 91啪亚洲精品 | 欧美日韩国产精品一区二区 | 亚洲精品美女视频 | 中文字幕一区二区三区精彩视频 | 九色 在线| japan25hdxxxx日本| 午夜影院在线免费观看视频 | 成人精品福利 | 精品真实国产乱文在线 |