Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does laravel turn off csrf authentication

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces laravel how to turn off csrf verification, the article is very detailed, has a certain reference value, interested friends must read it!

Laravel turns off csrf verification: 1. Open Kernel.php and comment "App\ Http\ Middleware\ VerifyCsrfToken"; 2. Open VerifyCsrfToken.php and specify the URL that is excluded from CSRF verification.

The operating environment of this tutorial: windows7 system, Laravel5.1 version, DELL G3 computer.

Laravel 5.1 turn off csrf authentication:

Description:

Laravel enables the CSRF function by default, and sometimes it may not be able to pass the verification token, so it needs to be turned off.

Method 1 (Global shutdown):

Open the file: app\ Http\ Kernel.php

Comment out this line:

'App\ Http\ Middleware\ VerifyCsrfToken'

Method 2 (partial shutdown):

Modify the file app\ Http\ Middleware\ VerifyCsrfToken.php.

In protected $except = [], specify the URL that is excluded from CSRF validation

Example:

Protected $except = [/ / close the request that begins with api 'api/*', / / turn off the request with .htm' * .htm *]; the above is all the content of the article "how to turn off csrf authentication by laravel". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report