A
A
AleDv2016-11-08 19:00:04
Laravel
AleDv, 2016-11-08 19:00:04

Laravel 5: Why am I getting an intermediate page on redirect?

Hello. There is this code with a simple form validation, which is placed on the page:

if($request->filter){

            $v = Validator::make($request->all(), (new Requests\HypothecCalcRequest())->rules(), (new Requests\HypothecCalcRequest())->messages());

            if ($v->fails()){
                return redirect()->back()->withErrors($v->errors());
            } else {
                $calculatorTable = Hypothec::annuitCalculator($request);
            }

        }

....

        return view('hypothec.index', $params);

The problem is that if the request does not pass validation, then before redirecting the user is redirected to an intermediate page with the content Redirecting to http://mysite.local, and only then the redirect itself occurs.
Tell me, what did I do wrong that this intermediate page occurs and why does it occur at all?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mikhail Osher, 2016-11-08
@miraage

Symfony wants it that way .

H
holfza, 2016-11-08
@holfza

I had this because of var_dump

A
AleDv, 2016-11-08
@AleDv

I checked, there are no echo, var_dump, dump, dd outputs, nothing like that. Validation takes place at the very beginning of the method, there is no code before it.

D
Denis, 2016-11-08
@prototype_denis

The "intermediate" page appears if the redirect was not a HEAD (GET) method.
That is, in your case, when sending data using the POST method and passing the validation, you throw out a redirect to the GET method and everything is fine ...
But if the validation fails, you redirect to the same page using the POST method.
Roughly speaking, if after submitting the form you press F5 in the browser, then an alert will pop up in the browser itself: Resend data? - Should sound familiar...
So in this case RedirectResponse does an explicit GET redirect. If this did not happen, then you would not be able to refresh the page after such a redirect - the browser would issue an alert.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question