rollbar / rollbar/rollbar-react
Next.js AppRoute Example: How can we log an error in the middleware
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46
- Forks
- 9
- Avg merge
- 2d 56m
- Merged PRs (30d)
- 4
Description
Hi, I tried the Next.js App Router example. (#122)
I modified the middleware to log error.
Before
After
export function middleware(request: NextRequest) {
rollbar.configure({ payload: { context: request.nextUrl.pathname } });
rollbar.error('error!', (err, response) => {
// insufficient privileges: post_client_item scope is required but the access token only has post_server_item.
console.log('error', err, response);
});
return NextResponse.next();
}
But as commented above, this causes insufficient privileges error.
If I change the server token to a client post token here:
The middleware can log the error.
But should I use the client post token in the middleware?
Is there a way to recommend?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with examples/nextjs-approuter/src/app/middleware.ts and examples/nextjs-approuter/src/rollbar.ts at the linked lines. Trace how the middleware token is configured and compare the permissions required by the attempted logging call. Done means the example or its documentation clearly recommends the appropriate token usage and explains the insufficient-privileges behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, typescript
- Domain
- documentation, security, web-dev
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100