在我的 nuxt 3 应用程序中,为了获取数据,我想为所有 API 调用设置一个基本 URL。当我从环境变量中获取这个 baseURL 时。如何设置baseURL?
我用可组合项扭曲 useFetch ,但随后我无法获取 baseURL,因为 useRuntimeConfig() 在那里不可访问。
// My composables function
const baseURL = "how to get baseURL from process.env";
export const myFetch = async (url: string) => {
const options = {
baseURL: baseURL,
};
return await useFetch(url, options);
}
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号