Replies: 8 comments 15 replies
-
I'm going to convert this to a discussion so it can go through our new Open Development process. Please upvote the new Proposal if you'd like to see this considered! |
Beta Was this translation helpful? Give feedback.
-
It would be a breaking change to start treating same-origin absolute redirect URLs as hard redirects, so a few APIs have been tossed around in discussion in related issues: 1. Custom Header redirect("https://currentorigin.com/hard-reload-path", {
headers: {
"X-Remix-Hard-Redirect": "true"
}
});
// We should know the origin so we should be able to make this work as well if desired
redirect("/hard-reload-path", {
headers: {
"X-Remix-Hard-Redirect": "true"
}
}); The downside here is that the user would need to know the header and I don't think it's something types can help out with because it's part of 2. Additional redirect("https://currentorigin.com/hard-reload-path", null, { hardRedirect: true }); This is awkward because now we've got an optional |
Beta Was this translation helpful? Give feedback.
-
I think it could be considered a "bug" and not a breaking change. If my react-router app has a basename, I would expect that a fully-qualified domain redirect would check the domain + the basename, and not just domain. So instead of all absolute redirect URLs being hard redirects, only those that are either:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
We've been running this in production for a bit now and has been working well. Took the ideas from here and @rossipedia's naming suggestion. You can checkout the diff here:
Usage looks like
Happy to open a PR for this if there is interest to have this as a contribution! |
Beta Was this translation helpful? Give feedback.
-
I gave the given workaround a shot but have concluded this needs to be fixed internally by remix for the following reasons:
For an example of a use case that needs this behavior, we are building an IDP in Remix that on successful login will redirect the user to another site that may be on the same domain. Currently we have found patching remix to be the best approach, but this is difficult to keep updated. |
Beta Was this translation helpful? Give feedback.
-
I took a shot at adding support for the |
Beta Was this translation helpful? Give feedback.
-
This will be handled by remix-run/remix#7040 and available in Remix v2 |
Beta Was this translation helpful? Give feedback.
-
What is the new or updated feature that you are suggesting?
Continued from the conversation with @brophdawg11 in #9590 (comment)
I'm currently migrating a PHP app to Remix, and doing it incrementally thanks to nginx:
If I do a
redirect()
from/b
to/a
, Remix tries to handle it like it's one of his routes, and it fails.We need to be able to do a same domain "hard" redirect.
One of the solutions could be to consider absolute redirects as hard redirects, and keeping relative ones as SPA redirections.
Why should this feature be included?
This would make it easier for folks to gradually migrate an online website, and would provide a happy path doing so.
My current workaround is to redirect from
/b
to a subdomain which in turns redirects again to/a
, which is far from ideal.Beta Was this translation helpful? Give feedback.
All reactions