Skip to content

[nuxt] SENTRY_ENVIRONMENT not working anymore #19238

@Diologenes

Description

@Diologenes

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nuxt

SDK Version

10.38.0

Framework Version

nuxt 4.3.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

nuxt.config.ts:

export default defineNuxtConfig({
  modules: [
    '@sentry/nuxt/module',
  ],
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },
  sentry: {
    autoInjectServerSentry: 'top-level-import',
    enabled: true,
    sourceMapsUploadOptions: {
      org: 'sentry',
      project: 'my-project',
      url: 'https://sentry.example.com',
      telemetry: false,
    },
  },
})

sentry.server.config.ts:

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

Sentry.init({
  dsn: 'https://just-a-domain.de/123',
  tracesSampleRate: 1.0,
  normalizeDepth: 10,
  debug: false,
});

Some example api route in server/api/sentry-test to trigger sentry:

import { defineEventHandler } from 'h3';
import * as Sentry from '@sentry/nuxt';

export default defineEventHandler(async () => {
    Sentry.captureMessage('My Test', {
        level: 'info',
        contexts: {
            task: { status: 'complete' },
        },
    });

    return {};
});

Steps to Reproduce

Fresh nuxt 4.3.1 installation with:
@sentry/nuxt 10.38.0
dotenv 17.2.4

Adding the following line to .env:
SENTRY_ENVIRONMENT=local

Expected Result

Sentry is logging my event with "environment": "local"

Actual Result

Sentry creates a new Event with "environment": "development" (when using "pnpm run dev") or "production" (when using the build command).

The value for SENTRY_ENVIRONMENT is ignored.

Additional Context

@sentry/nuxt 10.32.1 is the last version where SENTRY_ENVIRONMENT in .env was working.
Since @sentry/nuxt 10.33.0 the value for SENTRY_ENVIRONMENT is completely ignored.

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions