vike: `throw Redirect()`
Description
Itโs arleady possible with https://vite-plugin-ssr.com/RenderErrorPage#redirection but the DX should be polished.
We should:
- Create a second utility
throw Redirect() - Make
pageContext.redirectToa built-in property - Update all server integration examples
- Automatically redirect
/some/url/to/some/url
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 9
- Comments: 16 (13 by maintainers)
Commits related to this issue
- prepare infrastructure for new render abort utilities (#926) — committed to vikejs/vike by brillout 3 years ago
- feat: renderErrorPage() (and prepare infra for other abort hooks) (#926) — committed to vikejs/vike by brillout 3 years ago
- fix: improve logging of abort errors (#926) — committed to vikejs/vike by brillout 3 years ago
- implement renderUrl() (#926) — committed to vikejs/vike by brillout 3 years ago
- improve type of renderErrorPage (#926) — committed to vikejs/vike by brillout 3 years ago
- errorReason -> abortReason (#926) — committed to vikejs/vike by brillout 3 years ago
- errorReason -> abortReason (#926) — committed to vikejs/vike by brillout 3 years ago
- improve rendering abort logging (#926) — committed to vikejs/vike by brillout 3 years ago
- feat: redirect() (#926) — committed to vikejs/vike by brillout 3 years ago
- fix: consolidate `throw renderErrorPage()` and `throw renderUrl()` into a single utility `throw render()` (#926) — committed to vikejs/vike by brillout 3 years ago
- docs: rewrite docs about URL redirects/rewrites (#926) — committed to vikejs/vike by brillout 3 years ago
- docs: rewrite docs about URL redirects/rewrites (#926) — committed to vikejs/vike by brillout 3 years ago
- docs: rewrite docs about URL redirects/rewrites (#926) — committed to vikejs/vike by brillout 3 years ago
- fix: hide redirect() statusCode option (#926) — committed to vikejs/vike by brillout 3 years ago
- feat: `reload()` (#926) — committed to vikejs/vike by brillout 3 years ago
- fix: improve error upon aborting pre-rendering (#926) — committed to vikejs/vike by brillout 3 years ago
- also warn when calling reload on the server-side (#926) — committed to vikejs/vike by brillout 3 years ago
- impl abort for pageContext JSON requests (#926) — committed to vikejs/vike by brillout 3 years ago
- refine _pageContextInitHasClientData (#926) — committed to vikejs/vike by brillout 3 years ago
- fix workaround for fetching additional client-side pageContextInit data (#926) — committed to vikejs/vike by brillout 3 years ago
Quite a tempting alternative:
But letโs see if it works out. (There are some slight argument conflicts.)
Done:
Leaving this open until permanent redirections with
config.redirectsare implemented.I think this us a good compromise! Keeps the API simple but allows full control for those who are in need ๐๐ผ
@brillout ๐๐ผ
I think there could be an argument for having
302and301/308and therefore, Iโd be in favor to keep them. Example: a very content-driven website wants to indicate whether something has been moved temporarily and permanently based on query params or the content itself.I also think there is little overhead in this and making the arguments explicit even helps, because otherwise me as a developer would start to check the documentation to understand which status code is actually used.