You are being redirected. when redirecting from Phoenix controller

On Firefox:

conn
|> Plug.Conn.put_status(resp.status_code)
|> put_flash(:error, resp.body)
|> redirect(to: credit_card_path(conn, :index))

How can I just redirect without showing this screen?

2 Likes

It “shouldn’t” be showing that screen. Redirect sets a Location header with 302 to immediately redirect, so the browser shouldn’t be showing the body, it should immediately redirect, the body is a fallback for ancient browsers or curl or so.

2 Likes

I’m using Firefox Developer Edition. Do you think it’s just the browser intercepting this redirect in a misguided attempt at user-security?

I remember this same code used to just redirect like you’d expect.

Or because it’s a dev edition it does that to let you inspect the redirection flow?

Just to make sure, your status code is a redirection status code (302/303/etc…) yes?

4 Likes

Marking this as solved! The status code was NOT coming back a 302 for some reason. Pinging our API team :smiley:

Thanks for the assist @OvermindDL1

2 Likes

Lol, that would do it. I should remember more to check the basics first. “Is it plugged in?” ^.^;