Skip to content

In Next.js-project, errors inside pages/api not caught by Sentry when deployed on Vercel #11708

Closed

Description

@Danane84

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.111.0

Framework Version

Next.jsj 13.5.6

Link to Sentry event

No response

SDK Setup

Sentry.init({
dsn: SENTRY_DSN,

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
});

Steps to Reproduce

Create a Next.js app, add Sentry, deploy on Vercel

Expected Result

Errors from the pages/api folder are reported in Sentry, when deployed on Vercel

Actual Result

Errors from the pages/api folder are not reported in Sentry, when deployed on Vercel

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 21, 2024
  2. s1gr1d commented on Apr 22, 2024

    @s1gr1d
    Member

    Hello, thanks for reaching out! Did you use the wizard for setting up Sentry or did you set it up manually?

    Where did you set up init? If you haven't already, you need to set up the init function in sentry.server.(js|ts) to make it work on the server-side.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 22, 2024
  4. Danane84 commented on Apr 22, 2024

    @Danane84
    Author

    Hi Sigrid, thanks for your quick reply!

    I set up Sentry by using the wizard. My init is located in sentry.server.config.js inside the root-directory of my project and looks as follows:

    import * as Sentry from "@sentry/nextjs";
    import { SENTRY_DSN } from "./config";
    
    Sentry.init({
      dsn: SENTRY_DSN,
    
      tracesSampleRate: 1,
    
      debug: false,
    });
    

    Liebe Grüße von Wien nach Wien ;)

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Apr 22, 2024
  6. s1gr1d commented on Apr 22, 2024

    @s1gr1d
    Member

    Servus!

    This setup seems correct so far. Some additional things you could check:

    • Is the SENTRY_DSN variable defined?
    • Can you post the debug logs? (after setting debug: true)
    • Are you using Vercel Edge?
  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions