NuxtN
Nuxtβ€’14mo ago
Wirkhof

Unable to restrict /es/admin path

I am using i18n Nuxt extension.

This is my code:
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  modules: ['@nuxtjs/i18n'],
  i18n: {
    vueI18n: './i18n.config.ts',
    locales: ['en', 'es'], // used in URL path prefix
    defaultLocale: 'en',
    customRoutes: 'config', // disable custom route with page components
    pages: {
      about: {
        en: '/about-us', // -> accessible at /about-us (no prefix since it's the default locale)
        es: '/sobre', // -> accessible at /es/sobre
      },
      'admin/index': false,
      'admin/*': false, <----- doesn't work
    },
  },
});


I can visit /admin and cannot visit /es/admin . That's great and as expected.

But I can visti both /admin/settings and /es/admin/settings. Which is not good.

How to use stars or regex or something to block every other subpath for /es locale/prefix?
Was this page helpful?