1

This might be a really dumb question, but while trying to setup Cloudinary on my Nuxt application, I couldn't figure out how to utilise privateRuntimeConfig to pass the necessary keys to the Cloudinary plugin, because all of it is happening inside nuxt.config.ts.

Meaning, that at the same place where I use privateRuntimeConfig, inside nuxt.config.ts, is also where I need to pass them to the Cloudinary plugin configuration, but this won't work. So how do I go about this?

export default defineNuxtConfig({
    privateRuntimeConfig: {
        cloudinary: {
            cloudName: process.env.CLOUDINARY_CLOUD_NAME,
            apiKey: process.env.CLOUDINARY_API_KEY,
            apiSecret: process.env.CLOUDINARY_API_SECRET
        }
    },
    cloudinary: {
        cloudName: '', // ??
        apiKey: '', // ??
        apiSecret: '', // ??
    }
})

I feel like there is an obvious solution to this that I currently just can't see because there is a knot in my brain.

kissu
  • 40,416
  • 14
  • 65
  • 133
Nachtfunke
  • 329
  • 1
  • 14
  • Does this answer your question? [How to use .env variables in Nuxt 2 or 3?](https://stackoverflow.com/questions/67703133/how-to-use-env-variables-in-nuxt-2-or-3) – kissu Nov 04 '21 at 18:53

1 Answers1

1

When using variables for modules like here (directly into nuxt.config.js/ts), you cannot reference the runtime variables.

Simply use it directly like process.env.CLOUDINARY_CLOUD_NAME.
More info on my complete answer here: https://stackoverflow.com/a/67705541/8816585

kissu
  • 40,416
  • 14
  • 65
  • 133
  • But aren't they then accessible in the client and thus not secure? – Nachtfunke Nov 05 '21 at 10:14
  • Since it's the official module, I do think that the module will only use those credentials during the build time (server side only) and will not expose those publicly on runtime on the client side. It would be really stupid if the official module is not following the basics of security, but since it is done by [Maya](https://github.com/nuxt-community/cloudinary-module/graphs/contributors), I do think that this one is totally okay. @Nachtfunke – kissu Nov 05 '21 at 10:23