Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 316
Marian Klühspies Avatar asked Nov 01 '25 16:11

Marian Klühspies


1 Answers

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
    }
  },
like image 103
Marian Klühspies Avatar answered Nov 04 '25 12:11

Marian Klühspies