Logo
ProductChangelogPricing
Try it free
Logo
Logo
DocsPrivacyTermsRSS

©Quotion 2025. All rights reserved.

Made with
  1. Post
  2. How to fix Sentry /tunnel HTTP 405 error

Engineering

2 min read

How to fix Sentry /tunnel HTTP 405 error

Written by

QI

Qing

Creator, Quotion

Published on

1/27/2024

Table of contents

TLDR

#Engineering

The image showcases the Sentry platform, highlighting an 'Internal Server Error' with a stack trace. A cartoon character points a flashlight at the error code, emphasizing the debugging process. The overall mood is informative and problem-solving-oriented, with visual elements including code snippets, issue tracking options, and a clean, purple-themed interface.

TLDR

Just add /tunnel or /monitoring routes to your Next.js middleware matcher ignored list, these routes should be rewritten to Sentry’s service, don’t need to be handled by your Next.js middleware.

Sentry is a popular service used to monitor product errors, which Quotion is also using.
I build Quotion with Vercel Platforms Starter Kit, and Sentry works well with this shiny new technology. However, we encountered an HTTP 405 error on our production, like this:

The image displays a network request inspection tool, likely within a web browser's developer tools. The 'Headers' tab is selected, revealing details about a specific request to 'tunnel?o=4506359284236288&p=4506359293607936,' which resulted in a '405 Method Not Allowed' status. The interface is clean and functional, with a light green background and a focus on technical data.

I checked the Sentry docs, but nothing helped. One day, while searching for something inside the Next.js build output folder .next, I found that the Sentry /tunnel API is being used for rewriting to Sentry's API:

The image displays a code snippet from a routes-manifest.json file, likely part of a web application's routing configuration. The code defines rewrite rules, including a 'tunnel' route that appears to handle requests with specific query parameters like 'o' and 'p'. The overall mood is technical and focused, showcasing the inner workings of a web application's routing logic.

That's when I realized why this 405 error was occurring. Vercel Platforms Starter Kit rewrites almost everything to subfolders to create a multi-tenancy platform. Therefore, we need to bypass this special /tunnel API in the Next.js middleware. Based on my middleware matcher configuration, I only need to change the Sentry configuration to <strong>/api/tunnel</strong>. For example, this is my middleware configuration:

export const config = {
  matcher: [
    /*
     * Match all paths except for:
     * 1. /api/ routes
     * 2. /_next/ (Next.js internals)
     * 3. /images/ (static images)`
     * 4. /_static (inside /public)
     * 5. /_vercel (Vercel internals)
     * 6. all root files inside /public (e.g. /favicon.ico)
     */
    '/((?!api/|_next/|images/|_static|_vercel|[\\w-]+\\.\\w+).*)',
  ],
};

If you don't want to change the Sentry configuration, you can also add your Sentry API to the matcher RegExp:

export const config = {
  matcher: [
    //         👇
    '/((?!api/|tunnel|_next/|images/|_static|_vercel|[\\w-]+\\.\\w+).*)',
  ],
};

Create your blogs directly from Apple Notes.

Say goodbye to complex CMS updates and management issues!

You focus on creating quality content while Quotion takes care of the rest.

Learn MoreTry It Free

Subscribe to Quotion

Get the latest posts delivered to your inbox. No spam, unsubscribe anytime.

We care about your data in our privacy policy.

Latest

More from the site

    Qing

    AppleNotes

    Apple Notes Updates 2024

    #AppleNotes iPad18 & iOS18 introduced many powerful new features for Apple Notes. Math Notes There is a new Math Notes folder in the Notes app, which you can type or write out mathematical expression

    Read post

    Qing

    AppleNotes

    How to Share Apple Notes and Collaborate with Others

    #AppleNotes Did you know you can share your notes with other iCloud users in Apple Notes? Besides, you can also collaborate with others to work on the same notes, everyone can see each other's changes

    Read post

    Qing

    AppleNotes

    Use Templates in Apple Notes

    #AppleNotes If you use Apple Notes daily like me, you may want to use templates to setup your daily notes quickly. Since Apple Notes doesn't have a built-in template feature. Here are some apps I foun

    Read post

View all posts