學習 Laravel 那些坑(三) csrf_token()

來源:互聯網
上載者:User
laravel 5.5 填寫註冊資訊時遇到錯誤資訊
The page has expired due to inactivity. Please refresh and try again

http 狀態 419 Authentication Timeout (not in RFC 2616)

這時 url 已跳轉到 login,顯然登入時有問題;查了下是 csrf_token 的問題;
php - laravel 5.5 The page has expired due to inactivity. Please refresh and try again - Stack Overflow

題主命中的 answer是:

This problem comes from the CSRF token verification which fails. So either you’re not posting one, or you’re posting an incorrect one.

The reason it works for GET is that for a GET route in laravel, there is no CSRF token posted.

You can either post a CSRF token in your form by calling:

 {{ csrf_field() }}

Or exclude your route in app/Http/Middleware/VerifyCsrfToken.php

 protected $except = [        'your/route'    ];

試過了,然並卵;不是這種情況;

後來想到 csrf 會不會是.env 裡配置的問題,

 APP_URL=localhost

修改為訪問的 url,依然並卵;

後又修改 storage 許可權,問題解決。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.