question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@sentry/nextjs: NEXT_PUBLIC_SENTRY_DSN is not used

See original GitHub issue

Package + Version

  • @sentry/nextjs @ 6.4.0
  • @sentry/tracing @ 6.4.0

Description

According to a note at the end of the manual setup guide, you can use either the SENTRY_DSN or NEXT_PUBLIC_SENTRY_DSN environment variable to set Sentry’s DSN.

Setting NEXT_PUBLIC_SENTRY_DSN (such as through the official Sentry/Vercel integration) doesn’t configure the DSN. It appears that NEXT_PUBLIC_SENTRY_DSN isn’t referenced at all in the code, and SENTRY_DSN only appears to be supported by @sentry/node, leaving the client-side unconfigured.

Ideally, @sentry/nextjs would be updated to utilise these variables, or the documentation updated to remove this information.

Our current solution is to explicitly specify the DSN in sentry.client.config.js and sentry.server.config.js:

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  // ...
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
iker-barriocanalcommented, May 21, 2021

@AsherFoster yes, converted the docs PR to draft since this will be supported. I’ll keep this updated, and thanks for the feedback!

0reactions
HazATcommented, May 28, 2021

We use the NEXT_PUBLIC_SENTRY_DSN in the config file we create with the wizard see: https://github.com/getsentry/sentry-wizard/blob/master/scripts/NextJs/configs/sentry.client.config.js so we pick it up and use it if it’s there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manual Setup for Next.js - Sentry Documentation
Manual Setup. If you can't (or prefer not to) run the configuration step, you can follow the instructions below to configure your application....
Read more >
Sentry NextJS only work when the error occurs on the server ...
I must not only set a SENTRY_DSN because that'll only work in the server, but also NEXT_PUBLIC_SENTRY_DSN because that will be allowed by...
Read more >
@sentry/nextjs - npm
This package is a wrapper around @sentry/node for the server and @sentry/react for the client, with added functionality related to Next.js. To ...
Read more >
integrating Sentry in Next.js project - Stack Overflow
I am using Next.js with AMP. That means my code runs only on the server. no client code. I'm trying to integrate @sentry/node...
Read more >
Top 5 @sentry/node Code Examples - Snyk
To help you get started, we've selected a few @sentry/node examples, based on popular ways it is used in public projects. Secure your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found