i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Nuxt Bridge app.baseURL doesn't work with i18n module

Open thomas4Bitcraft opened this issue 3 years ago • 2 comments

Environment


  • Operating System: Darwin
  • Node Version: v14.18.1
  • Nuxt Version: latest
  • Package Manager: [email protected]
  • Bundler: Webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

nuxt.config.js

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
router: {
    base: '/d/'
  },
})

Describe the bug

The base path in nuxt bridge seems to be broken. If I set it to the above /d/ every preload link in the frontend is set to /d/d/ and all files are also reachable only with this path.

image image

It seems the only url which is not affected by this is the one to the header js file in production image

What makes the thing worse - because the file lies under /d/d/ and the whole site is broken

Additional context

No response

Logs

No response

Related Issue

nuxt/bridge#16

thomas4Bitcraft avatar Mar 01 '22 10:03 thomas4Bitcraft

With Bridge & Nuxt 3, we have a different way of configuring a dynamic base path:

  import { defineNuxtConfig } from '@nuxt/bridge'
  
  export default defineNuxtConfig({
-   router: {
-     base: '/d/'
-   },
+   app: {
+     baseURL: '/d/'
+   },
  })

This fixes the duplicated links in header but it doesn't seem to work with this module. Likely a change is needed to ensure that we pull not from router base but from the runtimeConfig, if it is set. (This should also be present on recent Nuxt 2 builds, even without Bridge).

danielroe avatar Mar 01 '22 14:03 danielroe

There is the https://i18n.nuxtjs.org/options-reference#baseurl option that should be used to make meta URLs fully-qualified and the base path should be included in here also.

Otherwise this module fully relies on the resolved values from Vue-Router and doesn't explicitly use router.base or app.baseURL anywhere.

Though I must say that VueRouter provides paths that both include and don't include the base path but module typically uses ones that don't include the base path as nuxt-link expects those.

rchl avatar Mar 01 '22 16:03 rchl