villus
villus copied to clipboard
Deploying to Vercel Edge function
When deploying Nuxt 3 project to Vercel Edge function, I get an error "Could not resolve a fetch() method, you should provide one". I managed to fix this by setting up Villus like this:
import { createClient } from "villus";
import { fetch as fetchPlugin } from "villus";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(
createClient({
url: `${nuxtApp.$config.public.backendUrl}/graphql`,
use: [fetchPlugin({ fetch })],
}),
);
});
By passing fetch to renamed fetch plugin, all works. I think this shouldn't be required and is probably issue with resolveGlobalFetch function not finding Vercel fetch. I haven't figured out how to modify it tho.