configurationnuxt3.jsbase-urlnuxt.config.js

How to set baseURL in Nuxt 3 in nuxt.config.ts instead of env


The documentation says:

By default, the baseURL is set to '/'. However, the baseURL can be updated at runtime by setting the NUXT_APP_BASE_URL as an > environment variable. Then, you can access this new base URL using config.app.baseURL:

https://nuxt.com/docs/api/composables/use-runtime-config#appbaseurl

However, I'd like to rather set it within the runtimeConfig property in my nuxt.config.ts

  runtimeConfig: {
    public: {
      site: {
        appName: ...
        description: ...
      },
      app: {
        baseURL: ... //not working
      }
    }
  },

How can I do that?


Solution

  • I was under the impression, that the app.baseUrl property belongs into the public object. But this instead works

    runtimeConfig: {
        public: {
          site: {
            appName: ...
            description: ...
          }
        },
        app: {
          baseURL: ... // working
        }
      },