export default defineNuxtPlugin(() => {
const { apiDomain } = useAppConfig();
const $apiFetch = $fetch.create({
baseURL: apiDomain,
onRequest({ options }) {
const localeCookie = useCookie('i18n_redirected');
if (localeCookie.value) {
options.headers.set('X-Localization', localeCookie.value);
}
},
});
// Expose to useNuxtApp().$apiFetch
return {
provide: {
apiFetch: $apiFetch,
},
};
});
export default defineNuxtPlugin(() => {
const { apiDomain } = useAppConfig();
const $apiFetch = $fetch.create({
baseURL: apiDomain,
onRequest({ options }) {
const localeCookie = useCookie('i18n_redirected');
if (localeCookie.value) {
options.headers.set('X-Localization', localeCookie.value);
}
},
});
// Expose to useNuxtApp().$apiFetch
return {
provide: {
apiFetch: $apiFetch,
},
};
});