natelindev / tsdav

WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser
https://tsdav.vercel.app
MIT License
227 stars 37 forks source link

Cloudflare Workers : crossFetch2.fetch is not a function #215

Open mathieunicolas opened 2 weeks ago

mathieunicolas commented 2 weeks ago

Hello there,

I'm trying to create a small caldav client on my web app using Nuxt/Nuxt Hub which is using cloudflare workers. Everything works fine on my local dev server, but when I try to make it work after deploying on cloudflare workers, I have this error, and I'm stuck.

I'm quite new with cloudflare workers and I don't really know how to make it work. Just spent 5 hours trying many things, but I'm not able to get something working.

Any idea ?

Thanks !

My API route is quite simple :

import { createDAVClient } from 'tsdav'

export default defineEventHandler(async (event) => {
  const { appleId, appleOtp } = useRuntimeConfig(event)

  const client = await createDAVClient({
    serverUrl: 'https://caldav.icloud.com',
    credentials: {
        username: appleId,
        password: appleOtp,
    },
    authMethod: 'Basic',
    defaultAccountType: 'caldav',
  })

  const cals = await client.fetchCalendars();

  return cals
})
natelindev commented 6 days ago

will add support in the future.