Issue
My Next.js app is not sending events to Sentry. In the browser Network tab, requests to my Sentry tunnel path (often /monitoring or another tunnelRoute value) fail with status codes such as 401, 403, or 500.
Applies To
All SaaS Customers (
tunnelRoutedoes not work with self-hosted Sentry)@sentry/nextjstunnelRouteinwithSentryConfigError Monitoring
Symptoms
Browser Network tab shows failed requests to the tunnel path
Client events never appear in Sentry
Failures can show 401, 403, 500, or similar status codes
Resolution
tunnelRoute sends Sentry traffic through a path on your Next.js app so ad blockers are less likely to drop it. If middleware or your host blocks that path, events never leave the browser.
Confirm the path in
withSentryConfig(for exampletunnelRoute: "/monitoring"ortunnelRoute: "/sentry-tunnel"). Use a fixed string path, nottunnelRoute: true, if you need to exclude it from middleware.If you use Next.js middleware (
middleware.ts, orproxy.tson Next.js 16+), exclude the tunnel path from the matcher so middleware does not run on it:
export const config = {
matcher: [
"/((?!monitoring|_next/static|_next/image|favicon.ico).*)",
],
};
Replace monitoring with your tunnel path segment (for example sentry-tunnel). See the Next.js middleware matcher documentation (not built or maintained by Sentry).
If the matcher change does not apply, delete the
.nextfolder (and any other build cache) and rebuild.If you use Turbopack and middleware still intercepts the tunnel, keep a fixed
tunnelRoutestring and the negative matcher above. See the tunnelRoute build option.If the failure only happens in production (or never on localhost) and middleware is already excluding the route, check hosting or platform rules that block or rewrite that path. Contact your hosting platform administrator for those settings.
See Tunneling in the Next.js manual setup for the recommended fixed-route pattern. The tunnel is implemented with Next.js rewrites. See the Next.js rewrites documentation (not built or maintained by Sentry).
