-
Notifications
You must be signed in to change notification settings - Fork 1k
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
wip(auth): Get fresh token before making request #1577
Conversation
I'm a bit cautious of this approach, since it changes a bunch of assumptions and I'm not fully grokking the consequences of that. Backing up a bit. I think the root cause for this problem is that we're not dynamically requesting the auth token on each request. This is solvable in Apollo by using an http auth-link (pseudo-code): import { AuthContext } from '@redwoodjs/auth'
const authLink = setContext((_, { headers }) => {
// get the authentication token
const { token } = AuthContext._currentValue
// return the headers to the context so httpLink can read them
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
}
}
}); |
My redwood app is still pre-production, but I face this almost on a daily basis during development. Token expires and all subsequent navigation inside redwood gives a 500 status from the API. (I am using Firebase as well). Would the above suggestion with auth-link be implemented on global level in redwood or on an auth provider level? |
@viperfx We'll solve this for everyone. |
Closing this, new solution on the way. |
Starts fix for #1576