Secrets don't seem to work for NuxtJS

I’ve set a secret with `fly secrets set API_URL=“foo” but with the configuration in Nuxt as

  env: {
    apiUrl: process.env.API_URL || 'http://localhost:8080'
  },

Its still http://localhost:8080 in the application, whereas setting API_URL="foo" yarn dev locally, it will pick up the environment variable.

I must be missing something on fly.io… any suggestions?

The issue is most likely on build time. I’ve wrote a little bit about it for NextJS but should be the same for Next too:

Thanks for the suggestion. Looks like NuxtJS does this Nuxt - Nuxt configuration file

Unfortunately, I still haven’t gotten it to work.

Ah looks like using the publicRuntimeConfig works, but not privateRuntimeConfig, because I was accessing the value in a client-side method.

1 Like