403 在laravel 8 形式中使用@csrf 後被禁止

雛菊

我是編程的新手,尤其是 Laravel。我正在嘗試製作一個 CRUD,並且已經在前傳中添加了示例數據(使用 Docker)。我可以看到數據,但是當我嘗試使用表單創建新帖子時,我的代碼 419 頁面已過期。我知道這很正常,解決方案是將 @csrf 添加到表單中。但是這樣做之後,我得到了 403 Forbidden。我嘗試了很多,但找不到解決方案來解決它。如果有人能幫我解決我的問題,我會很高興。

這是我的 create.blade.php


@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">{{ __('Alle Gerichte') }}</div>

                <div class="card-body">
                <form action = "/recipe" method="POST">
                @csrf
                            <div class="form-group">
                                <label for="name">Name</label>
                                <input type="text" class="form-control" id="name" name="name">
                            </div>
                            <div class="form-group">
                                <label for="beschreibung">Beschreibung</label>
                                <textarea class="form-control" id="beschreibung" name="beschreibung" rows="5"></textarea>
                            </div>
                            <input class="btn btn-primary mt-4" type="submit" value="absenden">
                        </form>

                  <a class="btn btn-primary btn-sm mt-3 float-right" href="/recipe"><i class="fas fa-circle-up"></i>Zurück</a>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
你是

嗨,您已經創建了驗證規則

在 StoreRecipeRequest 中

去做

public function authorize()
    {
        return true;
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章