I installed fresh vue 3 app with cli, containing also vue router.
On my web I have put builded files into www/dist sub folder. Then in my php index file I linked all js/css files to /dist folder manually.
I have an image in component
<img class="discord-icon" src="@/assets/discord.png">
When I set publicHtml = '/dist' , everything works even image is shown, but for some reason my homepage gets redirected from original "www.page.com" to "www.page.com/dist"
I would like to have default "www.page.com" at homepage but also with working image, how can I achieve that ?
Edit : My router config (default from Manual cli install with router)
const routes = [
{
path: "/",
name: "Home",
component: Home
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
});
UPDATE : On vue discord I got adviced to create .htaccess for this, sadly I am not skilled enough to create one, or even know to which folder store it. Also I had another one already in there since I am using php framework (Nette)
This is how I got it working for now :
"publicPath: '/dist'" and "history: createWebHistory(process.env.BASE_URL)" where project is in "/dist" folder, so page goes www.page.com/dist. All work but. I go to "www.page.com" it redirects to "/dist" but when look in html it does not generate "/dist/css/chunk-vendors.css" so all imported css is missing. But when I hit refresh (going directly to www.page.com/dist) chunk-vendors.css is loaded. By default vendors.css is not in generated index.html so I guess its done by js. So i got evil thought of just paste that vendors.css link manually to my production index.html aand it works, althought when going to /dist url directly I end up with loading this style 2 times lol. Then I got even more evil thought and changed to 'history: createWebHistory("/")' , rebuilded for production and now i have nice www.page.com and even all imported styles are working (with that style link pasted in manually), just have some feeling I will burn in hell.
vue-router
config. Your question doesn't show enough context to reproduce the problem. – tony19