403 Forbidden after using @csrf in laravel 8 form

  laravel, laravel-8, php

I am new to programming especially laravel. I am trying to make a CRUD and have already added example data in prequel (using Docker). I can see the data, but when I´m trying to create new posts with a form I get Code 419 page expired. I know that´s normal and the solution is to add @csrf to the form. But after doing this I get 403 Forbidden. I tried a lot but can´t find a solution to fix it.
I would be really happy if someone could help me fix my problem.

Here is my 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

Source: Laravel

Leave a Reply