perry-mitchell / webdav-client

WebDAV client written in Typescript for NodeJS and the browser
MIT License
661 stars 143 forks source link

cors error on call with ok preflight #347

Closed SINAKZM closed 10 months ago

SINAKZM commented 1 year ago

i wanna use nextcloud webdav api for my vue js application and get list of files and show in my component . i tried this:

      const client = createClient(
          "http://nextcloud_proxy_backend.develop/remote.php/dav/files/admin/",
          {
            username: "admin",
            password: "admin"
          }
      );
      const directoryItems = await client.getDirectoryContents("/");

i get cors error for main request and preflight request after i installed webappassword for nextcloud preflight is ok now with 204 status code but i still get cors error

Access to fetch at 'http://nextcloud_proxy_backend.develop/remote.php/dav/files/admin/' from origin 'http://localhost:8080' has been blocked by CORS policy: Method PROPFIND is not allowed by Access-Control-Allow-Methods in preflight response.

is my vue js code is correct? and could you give me tip for this ? i tried add header to nginx webserver but still got the same error

perry-mitchell commented 10 months ago

Looks like your CORS policy was incomplete:

Method PROPFIND is not allowed by Access-Control-Allow-Methods in preflight response.

Sorry for the huge lag in response.