Vue webHistory + Vite assets wrong relative path logic #8336
Unanswered
lucassonsinlima
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, I've an app using Vue 3 + Vite and I'm copying some font files from
node_modules
with vite-plugin-static-copy underfonts/xyz.woff2
. It works as expected when usingcreateWebHashHistory
onvue-router
because all routes are virtual routes and requests assets from/
. When I usecreateWebHistory
, assets are requested not only bydomain.com/fonts/xyz.woff2
but with all paths included likedomain.com/path1/path2/fonts/xyz.woff2
causing 404. I'm digging into this and seems like this vite section fallbacks todocument.baseURI
whendocument.currentScript
isnull
, and at this timedocument.currentScript
isnull
and when we do something likenew URL('/fonts/xyz.woff2', document.baseURI)
it will return the issue as expected. I don't know if there's any workaround for this but I tried to use all vite configs like setting origin, base etc..I can build an reproduce for this on vite issues, comparing with webpack bundling too (currentScript is not null at this point with webpack), but I'm starting with a discussion first :)
Beta Was this translation helpful? Give feedback.
All reactions