NavMeshAgent direction restriction

So i have a script for an enemy that follows a player:

using UnityEngine;
using UnityEngine.AI;

[DisallowMultipleComponent]
[RequireComponent(typeof(NavMeshAgent))]
public class MazeEnemy : MonoBehaviour
{
    // Private Variables
    private Transform player;
    private NavMeshAgent agent;

    private void Start()
    {
        player = FindFirstObjectByType<Player>().transform;
        agent = GetComponent<NavMeshAgent>();
    }

    private void FixedUpdate()
    {
        agent.SetDestination(player.position);
    }
}

but i need him not to be able to turn around and go backwards, but instead find a way round

You can attach a child object behind the enemy and add a NavMesh obstacle component to the child object with ‘Carve Only Stationary’ disabled.

now instead of turning around and walking backwards, the enemy turns 2 times to the left and walks forward😭