Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support custom redirect statuses #3204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coladarci
Copy link

For SEO reasons, it can be critical to provide a 301 versus the default 302 for redirects on mount.

This PR allows people to pass in status: 301 along with their to: "/some-path" and have the provided status code be used when redirecting.

The two reasons this PR was a little more invasive than originally thought:

  1. The redirect function in live view was setup to enforce that only to or external could be provided; no additional opts.
  2. Phoenix.Controller.redirect requires the use of put_status versus simply passing the status as an option (I believe the latter used to be possible, but no longer is). You'll see I'm stripping the status out of the opts after the put_status call.

Thanks for all you do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant