php - Laravel redirect()->back() return me iframe

I am having problem in Laravel with redirect back.

I used this code for set lang to sessions:

   Route::get('/lang/{locale}', function ($locale){

    Session::put('locale', $locale);
    return redirect()->back();
 
});

works fine.

But on several pages, I have used iframe with route inside:

<iframe src="{{route('wizzard')}}" width="800px" height="650px">
</iframe>

Problem: Why does ->back() return Route "wizzard" from iframe instead of the original page when there is iframe?

How can I make laravel ignore the iframe inside when it returns?

Answer

Solution:

i make URL check in route and now is ok...

    Route::get('/lang/{locale}', function (Request $request, $locale){

    Session::put('locale', $locale);

    $uri = str_replace(url('/'), '', url()->previous());

    if ($uri == '/wizzard'){
        return redirect('table');
    }

    return redirect()->back();
    
});

Source