Skip to content

[Vue Router warn]: The Matcher cannot resolve relative paths when baseURL and strategy: "prefix" is set #3887

@ItsuoSano

Description

@ItsuoSano

Environment


  • Operating System: Darwin
  • Node Version: v22.21.1
  • Nuxt Version: 4.2.1
  • CLI Version: 3.30.0
  • Nitro Version: 2.12.9
  • Package Manager: [email protected]
  • Builder: -
  • User Config: compatibilityDate, devtools, modules, i18n, typescript, app, experimental
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

reproduction

set nuxt.config.ts

app: {
  baseURL: '/12345'
}

and

i18n:{
  strategy: 'prefix'
}
  1. Open stackblitz reproduction page
  2. Open the page in new tab
  3. Reload the page.

console shows WARN [Vue Router warn]: The Matcher cannot resolve relative paths but received "345/en". Unless you directly called matcher.resolve("345/en"), this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.

Describe the bug

I believe the root cause of this bug is that app.baseURL (defined in nuxt.config.ts) is not taken into account when calculating the path.

const path = (pathLocale && url.pathname.slice(pathLocale.length + 1)) ?? url.pathname

Proposed Fix: I suggest modifying the code as follows:

const path = (pathLocale && event.path.slice(pathLocale.length + 1)) ?? event.path

sorry, I haven't checked for potential side effects.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions