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

3.2k Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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
    }
  },