Skip to content

fix: set router.base to app.baseURL#830

Merged
danielroe merged 5 commits intonuxt:mainfrom
wattanx:fix-base-url
Jul 4, 2023
Merged

fix: set router.base to app.baseURL#830
danielroe merged 5 commits intonuxt:mainfrom
wattanx:fix-base-url

Conversation

@wattanx
Copy link
Copy Markdown
Collaborator

@wattanx wattanx commented Jun 24, 2023

🔗 Linked issue

resolve: #16
resolve: #790

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Nuxt 2's router.base must use app.baseURL in Nuxt 3 and Nuxt Bridge.
Fixed the app.baseURL value to be set to _app.basePath, since the Nuxt 2 router must also be configured when using app.baseURL.
(Without this modification, both app.baseURL and router.base must be set.)

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe
Copy link
Copy Markdown
Member

Nuxt 2 has a very early concept of app.baseURL as _app.basePath here:

https://github.com/nuxt/nuxt/blob/18ae3e1d8b564fbdf78dbbc6963b8f90bcf07b0c/packages/vue-app/template/router.js#L105

and here:

https://github.com/nuxt/nuxt/blob/18ae3e1d8b564fbdf78dbbc6963b8f90bcf07b0c/packages/config/src/options.js#L467-L471

Maybe it would be worth respecting that instead?

@wattanx
Copy link
Copy Markdown
Collaborator Author

wattanx commented Jun 25, 2023

It looked better to use _app.basePath, so I fixed it!
Thank you!

Sorry, this implementation does not work with webpack and nitro: true.
I will fix it.

@wattanx
Copy link
Copy Markdown
Collaborator Author

wattanx commented Jun 26, 2023

There is some processing that depends on router.base and cannot be replaced by _app.basePath 😢
https://github.com/nuxt/nuxt/blob/18ae3e1d8b564fbdf78dbbc6963b8f90bcf07b0c/packages/webpack/src/config/client.js#L186

@danielroe danielroe changed the title fix: Set app.baseURL to router.base fix: set router.base to app.baseURL Jul 4, 2023
@danielroe danielroe merged commit ccb7c86 into nuxt:main Jul 4, 2023
@danielroe danielroe mentioned this pull request Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When router.base is set in the nuxt config the server will not build/preview correctly. Nuxt Bridge app.baseURL doesn't work with i18n module

2 participants