I am currently working on an application using Nuxt JS that communicates with an API located on another server in the server folder. After calling this API, I then fetch data from a Vue file. However, when I deploy the application using 'npm run generate', the network tab shows a 404 error for this particular route. Does anyone have any suggestions or ideas?
Here is a snippet of the code from the simple server/api/file
:
export default defineEventHandler(async (event) => {
const { public: base } = useRuntimeConfig(event);
const cookies = parseCookies(event);
const headers = {
"Accept-Language": cookies.ln,
};
const { data } = await $fetch(`mybaseurl/home`, {
headers: headers,
});
return data;
});
Later on, I call this file from within a vue.file
like so:
const { data, pending } = await useFetch("/api/home");
storeHome.setHomeData(data.value);