Add auth token propagation for Poetic Brain chat#326
Conversation
❌ Deploy Preview for sprightly-genie-998c07 failed. Why did it fail? →
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const token = getAuthToken(); | ||
| if (token) { | ||
| headers.Authorization = `Bearer ${token}`; | ||
| } |
There was a problem hiding this comment.
Refresh auth tokens before Raven requests
The Authorization header for every Raven call is populated from whatever value happens to be in localStorage (getAuthToken), but that token is only fetched once during the initial Auth0 bootstrap in RequireAuth (lines 111‑130) and is never refreshed. Auth0 access tokens expire (typically ~1h) and app/api/raven/route.ts rejects expired tokens via verifyToken, so any user who keeps the chat open past the token lifetime will start getting 401s even though the UI still marks them as authenticated. Without re‑calling getTokenSilently or another refresh path before setting this header, long-running sessions will break until the page is reloaded.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task