Skip to content
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

Next.js AppRoute Example: How can we log an error in the middleware #125

Open
konomae opened this issue Apr 9, 2024 · 1 comment
Open
Labels

Comments

@konomae
Copy link

konomae commented Apr 9, 2024

Hi, I tried the Next.js App Router example. (#122)

I modified the middleware to log error.

Before

export function middleware(request: NextRequest) {
rollbar.configure({ payload: { context: request.nextUrl.pathname } });
return NextResponse.next();
}

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:

accessToken: process.env.POST_SERVER_ITEM_TOKEN,

The middleware can log the error.
But should I use the client post token in the middleware?

Is there a way to recommend?

@linear linear bot added the Next.js label Apr 9, 2024
@alexookah
Copy link

I experienced the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants