NextJS Tunneling example could infinitely loop
Closed this issue · 1 comments
The API route for the Sentry tunnel in the NextJS example (https://github.com/getsentry/examples/blob/master/tunneling/nextjs/pages/api/tunnel.js#L35) calls captureException
if an error is encountered while reporting an error.
Because the Sentry client is configured to use this tunnel for reporting exceptions, I'd guess that we'd then infinitely recurse on this API method if there's an issue communicating with Sentry?
We recommend If you upgrade to Next.js SDK 7.26.0
or higher (we recommend using latest) you can use the tunnelRoute
option to automatically set up a tunnel. We recommend you use this option for tunneling instead of setting up your own.
See the docs: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-tunneling-to-avoid-ad-blockers
// next.config.js
const nextConfig = {
sentry: {
tunnelRoute: "/monitoring-tunnel",
},
};