Nuxt 3 project running in a subdirectory trying to find assets in root instead of subdirectory

161 Views Asked by At

I could run Nuxt 3 in a subdirectory after setting the app.baseURL in nuxt.config.ts as mentioned in the official documentation. https://nuxt.com/docs/api/configuration/nuxt-config#baseurl

It works fine on development, but on production after building, the assets included in app.head.link and app.head.script are not found as its source considering the root path instead of the subdirectory!

I tried to set app.cdnURL as mentioned in the official docs, but I hasn't any effect. https://nuxt.com/docs/api/configuration/nuxt-config#cdnurl

nuxt.config.ts file

export default defineNuxtConfig({
ssr: false,
   app: {
      baseURL: '/admin',
      cdnURL: '/admin',
      head: {
        link: [{ rel: 'icon', type: 'image/png', href: '/imgs/logo.png' },],
        script: [{ type: 'text/javascript', src: "/js/main.js", tagPosition: "bodyClose" },]
      }
})

appreciating you suggestions. Thank you.

0

There are 0 best solutions below