laravel 页面您将要提交的信息不安全,稍后部署时出现 419 页面过期错误

我有一个 Laravel 项目,已部署在 heroku 上。当我提交表单时它会打开,它最初显示“您要提交的信息不安全”,如果我仍然提交它,它会显示“419 页已过期”

我尝试了很多解决方案 我的表单样本是

>[-]>[-]+>[-]+
<<<[
    # if block
>>>-<<]>[<]>>[
    # else block
-]+

Laravel 419 Page Expired on production server. [ framework : Laravel | version : 7.5.2 ] Laravel 6 Showed 419 | page expired

我关注了这些链接,当我发表评论时

<!DOCTYPE html>
<html lang="{{ str_replace('_','-',app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>Upload File</title>
    
</head>
<body>

    <!-- store route as action -->
    <div class="container">
            <div class="row">
                <div class="col-12">

                <br><br><br>
    <form action="{{route('video')}}" method="post" enctype="multipart/form-data">
        @csrf
        {{ csrf_field() }}
        <input type="file" class="form-control" name="videothing" id="videotitle" accept=" video/*">
        <input type="submit" class="btn btn-sm btn-block btn-danger" value="Upload" onclick="spinner()">
    </form>
    
        
    @if (session('message'))
    <h1 id="v">{{ session('message') }}</h1>
@endif

在 kernel.php 中,错误停止但在提交表单时它不会重定向到路由而只是重新加载页面, 我确定这是 CSRF 问题,但无法解决

在我的 VerifyCsrfToken.php 中,我确实包含了

\App\Http\Middleware\VerifyCsrfToken::class,

我的 session.php 是

 protected $except = [
        //
        'https://laraveluploading.herokuapp.com/','https://laraveluploading.herokuapp.com/video',];

我的 web.php 有

<?php

use Illuminate\Support\Str;

return [

   

    'driver' => env('SESSION_DRIVER','file'),'lifetime' => env('SESSION_LIFETIME',120),'expire_on_close' => false,'encrypt' => false,'files' => storage_path('framework/sessions'),'connection' => env('SESSION_CONNECTION','mysql'),'table' => 'sessions','books','videos','store' => env('SESSION_STORE',null),'lottery' => [2,100],'cookie' => env(
        'SESSION_COOKIE',Str::slug(env('APP_NAME','laravel'),'_').'_session'
    ),'path' => '/','domain' => env('SESSION_DOMAIN','https://laraveluploading.herokuapp.com'),'secure' => env('SESSION_SECURE_COOKIE',false),'http_only' => true,'same_site' => 'lax',];

在我在 heroku 上的应用程序配置变量中,我添加了数据库凭据(在 azure 上)以及与谷歌驱动器连接所需的谷歌客户端 ID、密钥、刷新令牌。

我确实尝试了来自不同链接的其他解决方案,但没有用。 请帮我解决问题。

liaotengfei2008 回答:laravel 页面您将要提交的信息不安全,稍后部署时出现 419 页面过期错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2621.html

大家都在问