Skip to content

Sentry does not initialize in a backend-only Nuxt API #15617

@axel-trending-dev

Description

@axel-trending-dev

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

v9

Framework Version

Nuxt 3.15.1 + Node v22 + [email protected]

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from '@sentry/nuxt';

Sentry.init({
  dsn: '***',

  // TODO: We recommend adjusting this value in production, or using tracesSampler
  // for finer control
  tracesSampleRate: 1.0,

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

Steps to Reproduce

When using @sentry/nuxt in a backend-only Nuxt project (e.g., an API without a frontend), Sentry does not automatically capture errors, and even manual error capture (Sentry.captureException(error)) does not work.

It seems that Sentry only initializes when the frontend is engaged. The following logs appear when the frontend is accessed:
ℹ ✨ new dependencies optimized: @sentry/nuxt
ℹ ✨ optimized dependencies changed. reloading

However, if there is no frontend interaction, Sentry does not seem to start, and no errors are captured in the backend.

Steps to Reproduce

  1. Create a Nuxt project with a backend-only API (server/api/ handlers).
  2. Trigger an error in an API route.
  3. Observe that no errors are reported to Sentry.

Expected Result

Sentry should initialize and capture errors automatically, even in an API backend-only Nuxt setup.
Manual error capture (Sentry.captureException(error)) should work as expected.

Actual Result

Sentry is not capturing exceptions in an API backend-only Nuxt setup. Even manual error capture (Sentry.captureException(error)) is not working as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: nuxtIssues related to the Sentry Nuxt SDK

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions