Nuxt.js: html miss <base> when router.base just only have a slash

Created on 12 May 2017  路  9Comments  路  Source: nuxt/nuxt.js

When I just setting router.base with "/"
the html element can't find <base> element
It should have a<base href="/">

I tried use a simple project test vue-meta
I just set base.href = '/' html work fine .
screenshot_12

so , I thinks this belong nuxt.js issue .
I tried find problem in nuxt.js source but can't find ....

I propose this issus that because I have a project , in dev test is need a sub folder .
but production don't , so , my image url is like ./img/image.jpg
so , if html miss base in head , that will break the image .

for now , if I change router.base to '/' , I need add <base href="/"> in app.html template front {{ HEAD }} everytime ... ummm... even I already write it in my CI/CD ...

maybe if can fix this issue will be best .
thanks .

This question is available on Nuxt.js community (#c606)
available soon

Most helpful comment

@alexchopin @Atinux
thanks you brothers understanding .
ed3b3d25d801a279673e36ae808534d4

All 9 comments

my personal cognition

setting router.base = '/' and without setting router.base is different .

but seems it the same on nuxt.js at this moment .

Hi @ausir0726,
This is the vue-router base option: https://router.vuejs.org/en/api/options.html.
If you need to add head tag base, you need to create it like you did with the head option in nuxt.config.js.

Hi @ausir0726

It's here in the code https://github.com/nuxt/nuxt.js/blob/master/lib/render.js#L105

The base '/' creates problem in some cases if it exists, that's why we don't create directly.

@Atinux , Yes , I know .
but when user is clear setting nuxt.config.js router.base to '/'
maybe nuxt.js should not block this behavior .
because , If you block in nuxt.config.js , that I also need to add <base href="/"> in app.html
If will make problem in some cases , it's same have problem ...

I don't know my opinion is ok ?

@Atinux update my opinion .

Sorry for waste you valuable time .

You're right @ausir0726, when base is defined in nuxt.config.js, we should add <base href="/">.

Will update it for the next version.

@alexchopin @Atinux
thanks you brothers understanding .
ed3b3d25d801a279673e36ae808534d4

Thanks to you @ausir0726 for your precious help!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uptownhr picture uptownhr  路  3Comments

vadimsg picture vadimsg  路  3Comments

jaredreich picture jaredreich  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

danieloprado picture danieloprado  路  3Comments