Handling redirects in NextJS, can it be done from _app.tsx? #12682
Unanswered
rockchalkwushock
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to port over a Django GraphQL API from a CRA app to use NextJS. I've got
@apollo/client
working fine and am making use of it within_app.tsx
because the whole app makes use of the GraphQL endpoint. The Django app handles all the authentication views and redirects the user to anauth.html
in the current app that gets theaccess_token
out of the URL and gives it to the ApolloClient to make sure the user is authenticated to access the CRA App. I've been able to get that far. The problem I'm running into is that with the CRA App we sent the user to/
fromauth.html
, would run the viewer query, and if a user is foundreach-router
would then use the redirect feature to send the user to their dashboard at/profiles/[id]/meetings
. I'm not really sure how to do this in NextJS.An idea I have is to just create a
/pages/index.tsx
and if the UserContext is present then redirect to/profiles/[id]/meetings
using the Router API and if not for the time being just render an error message. Is there perhaps a better way of handling this from_app.tsx
?public/auth.html
pages/_app.tsx
Beta Was this translation helpful? Give feedback.
All reactions