nuxt-modules / supabase

Supabase module for Nuxt.
https://supabase.nuxtjs.org
MIT License
733 stars 129 forks source link

Option i18n for redirection #369

Open IgorKha opened 6 months ago

IgorKha commented 6 months ago

Good afternoon everyone! I am using a multilingual module (@nuxtjs/i18n and I use prefix_and_default strategy) and I have encountered the problem of multiple routes repeating in the config for each language

Here is an example of nuxt.config.ts configuration for supabase

supabase: {
    url: process.env.SUPABASE_URL,
    key: process.env.SUPABASE_KEY,
    redirect: true,
    redirectOptions: {
      login: 'login',
      callback: 'confirm',
      include: ['/bg/app(/.*)?', '/fr/app(/.*)?', '/app(/.*)?'],
      exclude: ['/login'],
      cookieRedirect: true
    },
}

Here is an example of nuxt.config.ts configuration i18n

i18n: {
    vueI18n: './i18n.config.ts',
    types: 'composition',
    strategy: 'prefix_and_default',
    defaultLocale: 'en',
    lazy: true,
    langDir: 'locales',
    locales: [
      {
        code: 'en',
        iso: 'en-US',
        name: 'English',
        nameEn: 'English',
        file: 'en-US.ts'
      },
      {
        code: 'bg',
        iso: 'bg-BG',
        name: 'Български',
        nameEn: 'Bulgarian',
        file: 'bg-BG.ts'
      },
      {
        code: 'ru',
        iso: 'ru-RU',
        name: 'Русский',
        nameEn: 'Russian',
        file: 'ru-RU.ts'
      },
      {
        code: 'fr',
        iso: 'fr-FR',
        name: 'Français',
        nameEn: 'French',
        file: 'fr-FR.ts'
      }
    ],
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'i18n_redirected',
      redirectOn: 'root'
    }
  }

Is it possible to add an option in the supabase setup that would avoid this problem?

Thank you!