nuxt3.js - Using @sentrynuxt module, how do i keep my DSN hidden from client-side? - Stack Overflow

When using @sentrynuxt: 9.3.0, you have to create sentry.client.config.ts in the root level of your ap

When using @sentry/nuxt: 9.3.0, you have to create sentry.client.config.ts in the root level of your app.

Example sentry.client.config.ts contents:

Sentry.init({
  dsn: 'sentry key'
})

problem is if i use:

export default defineNuxtConfig({
  runtimeConfig: {
    dsnKey: 'secret-key', // available only on a server-side
    public: {}, // exposed to a client-side
  }
)}

public variables will be exposed to a client side in a console window.__NUXT__

but dsnKey is usable only on the server side and sentry.client.config.ts is only a client-side, i don't want to use sentry.server.config.ts, because it will log all server-side errors. What choices do i have?

When using @sentry/nuxt: 9.3.0, you have to create sentry.client.config.ts in the root level of your app.

Example sentry.client.config.ts contents:

Sentry.init({
  dsn: 'sentry key'
})

problem is if i use:

export default defineNuxtConfig({
  runtimeConfig: {
    dsnKey: 'secret-key', // available only on a server-side
    public: {}, // exposed to a client-side
  }
)}

public variables will be exposed to a client side in a console window.__NUXT__

but dsnKey is usable only on the server side and sentry.client.config.ts is only a client-side, i don't want to use sentry.server.config.ts, because it will log all server-side errors. What choices do i have?

Share Improve this question asked 21 hours ago Alexander KimAlexander Kim 18.4k24 gold badges107 silver badges165 bronze badges 1
  • seems like stackoverflow is completely dead, since rise of AI :( – Alexander Kim Commented 21 hours ago
Add a comment  | 

1 Answer 1

Reset to default 0

If you want to use a variable on the client-side during runtime, you need to make it public. The client-side needs to see the DSN to know where to send the errors to.

Your frontend is always public. As soon as you open the browser inspection tools, you are able to see the (minified) code, the network requests etc.

Just make sure to keep your Sentry Auth Token secret - this one is only used during build time.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743768466a4503933.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信