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
Support dynamic redirect destinations #57
Comments
I like this idea a lot. It does provide flexibility both at CSR and SSR. Just a few comments / observations:
// ctx would be defined when server-side redirecting
// window is globally available for client-side
// AuthUser is available for custom logic to be built around
({ ctx, AuthUser }) => {
// handle CSR vs SSR
if (typeof window !== 'undefined')
// do CSR stuff here
else if (ctx)
// do SSR stuff here
// some logic
return '/my-auth-page?next=/my-app/'
} |
@tlays Thanks for the thoughtful feedback! I agree with all of your suggestions.
Yes
Yes
I agree
I agree, this is a good idea |
After this is implemented, we should also replace the "custom redirect" example added in #51. A simple demo would be to include the user's email in a URL parameter value when redirecting. |
Yes, or maybe add another (a new) example page specific for this redirect technique (with a dynamic redirect at CSR vs SSR). IMO, the example in #51 is still interesting to keep in order to illustrate how to use the built-in / standard SSR support for |
Any ETA on this awesome feature? :) Right now I do it like this (maybe that helps others): getServerSideProps
useEffect - I have this in _app.js so it works on every page
|
Closed by #121 and released in v0.13.0-alpha.3. |
Opened an issue to update the documentation and example: #122 |
Is your feature request related to a problem? Please describe.
As mentioned in the limitations, there isn't built-in support for custom redirect destinations based on the user's auth status. This limits the usefulness of the redirects.
Describe the solution you'd like and how you'd implement it
Allow users to provide functions for the
authPageURL
andappPageURL
config properties that should return the appropriate URL. We could pass eitherctx
orwindow
to the function, depending on the context.Is this a breaking change?
No. We would still support static values for the config options.
Describe alternatives you've considered
None
The text was updated successfully, but these errors were encountered: