Skip to content

Get my secret value in a fetch method ? #21

Description

@bat79a

Hi.

I'm trying to catch my secret value in a fetch method, can you tell me how to do that ?
Env vars works well but the secret env doesn't work.

I have tryed this in my index.vue :

async fetch ({ app, store, params, error, app: { $axios } }) {
  ...
  const oauthPassword = app.$env.OAUTH_API_PASSWORD => is empty
  const oauthPassword = this.$env.OAUTH_API_PASSWORD => is empty

  const oauthUser = app.$env.OAUTH_API_USER => Catch the good env from my kubernetes secrets
  ...
}

Here is my nuxt.config.js :

 modules: [
  ...
  ['nuxt-env', {
      keys: [
        { key: 'OAUTH_CLIENT_ID', default: 'abcd' },
        { key: 'OAUTH_API_HOST', default: 'https://oauth.io/' },
        { key: 'OAUTH_API_USER', default: 'my_user' },
        { key: 'OAUTH_API_PASSWORD', secret: true }
      ]
    }]
  ...

Thx a lot.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    more detail neededPlease provide an example or recreation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions