【问题标题】:How to set baseURL in Nuxt 3 in nuxt.config.ts instead of env如何在 nuxt.config.ts 中的 Nuxt 3 中设置 baseURL 而不是 env
【发布时间】:2023-01-07 00:51:49
【问题描述】:

文件说:

默认情况下,baseURL 设置为“/”。 但是,baseURL 可以在运行时通过将 NUXT_APP_BASE_URL 设置为 > 环境变量来更新。 然后,您可以使用 config.app.baseURL 访问这个新的基本 URL:

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

但是,我宁愿在我的 nuxt.config.ts 的 runtimeConfig 属性中设置它

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

我怎样才能做到这一点?

【问题讨论】:

    标签: configuration nuxtjs3 base-url nuxt.config.js


    【解决方案1】:

    我的印象是 app.baseUrl 属性属于公共对象。但这反而有效

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

    【讨论】:

      猜你喜欢
      • 2020-01-21
      • 2022-08-23
      • 2018-06-20
      • 2020-03-01
      • 2019-07-13
      • 2021-03-31
      • 2021-12-18
      • 2019-01-24
      • 2021-08-14
      相关资源
      最近更新 更多