STEN
STEN

Reputation: 443

Can I access nuxt context in nuxt.config.js?

I'm using nuxt-i18n and @nuxtjs/auth and I want to config the auth.redirect option to support i18n like this:

// nuxt.config.js

export default {
  modules: [
    '@nuxtjs/auth',
    'nuxt-i18n',
    // ...
  ],
  auth: {
    redirect: {
      home: localePath('/dashboard'),
      // ...
    },
  },
  // ...
};

Normally, just like this.$store, I can access that localePath function provided by nuxt-i18n through app instance or the context like this.$localePath or app.localePath. But how can use it inside the nuxt.config.js file?

Upvotes: 16

Views: 1945

Answers (1)

STEN
STEN

Reputation: 443

In case of @nuxt/auth module with i18n redirection support problem, I've found a workaround: https://github.com/nuxt-community/auth-module/issues/1116#issuecomment-824814739.

Credit @azrikahar

Upvotes: 1

Related Questions