Explain the Problem
I'm trying to access a public WebDAV share as described in https://docs.nextcloud.com/server/20/user_manual/en/files/access_webdav.html#accessing-public-shares-over-webdav.
Steps to Reproduce
- Add origins using web interface:
http://localhost:15755,http://localhost:15755/
- Make
fetch request with hash of share as username:
fetch("https://nx904.your-storageshare.de/public.php/webdav/", {
"headers": {
"accept": "application/xml,text/xml",
"authorization": "Basic cEZBOFBUd0NtSnlTVERqOg==",
"content-type": "application/xml;charset=UTF-8",
"depth": "1",
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"",
"sec-ch-ua-mobile": "?0"
},
"referrer": "http://localhost:15755/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": "<d:propfind xmlns:d='DAV:'>\n\t\t\t<d:prop>\n\t\t\t\t<d:displayname/>\n\t\t\t\t<d:resourcetype/>\n\t\t\t\t<d:getcontentlength/>\n\t\t\t\t<d:getcontenttype/>\n\t\t\t\t<d:getetag/>\n\t\t\t\t<d:getlastmodified/>\n\t\t\t</d:prop>\n\t\t</d:propfind>",
"method": "PROPFIND",
"mode": "cors",
"credentials": "include"
});
- The request fails due to CORS:
Access to fetch at 'https://nx904.your-storageshare.de/public.php/webdav/' from origin 'http://localhost:15755' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
wasm_exec.js:399 PROPFIND https://nx904.your-storageshare.de/public.php/webdav/ net::ERR_FAILED
It works using plain curl:
$ curl 'https://nx904.your-storageshare.de/public.php/webdav/' \
> -X 'PROPFIND' \
> -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"' \
> -H 'sec-ch-ua-mobile: ?0' \
> -H 'authorization: Basic cEZBOFBUd0NtSnlTVERqOg==' \
> -H 'content-type: application/xml;charset=UTF-8' \
> -H 'accept: application/xml,text/xml' \
> -H 'Referer: http://localhost:15755/' \
> -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \
> -H 'depth: 1' \
> --data-raw $'<d:propfind xmlns:d=\'DAV:\'>\n\u0009\u0009\u0009<d:prop>\n\u0009\u0009\u0009\u0009<d:displayname/>\n\u0009\u0009\u0009\u0009<d:resourcetype/>\n\u0009\u0009\u0009\u0009<d:getcontentlength/>\n\u0009\u0009\u0009\u0009<d:getcontenttype/>\n\u0009\u0009\u0009\u0009<d:getetag/>\n\u0009\u0009\u0009\u0009<d:getlastmodified/>\n\u0009\u0009\u0009</d:prop>\n\u0009\u0009</d:propfind>' \
> --compressed
<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/public.php/webdav/</d:href><d:propstat><d:prop><d:resourcetype><d:collection/></d:resourcetype><d:getetag>"608923d732f31"</d:getetag><d:getlastmodified>Wed, 28 Apr 2021 08:59:03 GMT</d:getlastmodified></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:displayname/><d:getcontentlength/><d:getcontenttype/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response><d:response><d:href>/public.php/webdav/2021/</d:href><d:propstat><d:prop><d:resourcetype><d:collection/></d:resourcetype><d:getetag>"608923d732f31"</d:getetag><d:getlastmodified>Wed, 28 Apr 2021 08:59:03 GMT</d:getlastmodified></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:displayname/><d:getcontentlength/><d:getcontenttype/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>
System Information
- WebAppPassword app version: 21.3.0
- Nextcloud version: 20.0.9
- Cron type: / (Hosted by Hetzner)
- PHP version: / (Hosted by Hetzner)
- Database and version: / (Hosted by Hetzner)
- Browser and version: Chrome 90, Firefox 88
- Distribution and version: Fedora Linux 34
Contents of nextcloud/data/nextcloud.log
(No access to logs, hosted by Hetzner)
Contents of Browser Error Console
Read http://ggnome.com/wiki/Using_The_Browser_Error_Console if you are unsure what to put here
Access to fetch at 'https://nx904.your-storageshare.de/public.php/webdav/' from origin 'http://localhost:15755' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
wasm_exec.js:399 PROPFIND https://nx904.your-storageshare.de/public.php/webdav/ net::ERR_FAILED
Explain the Problem
I'm trying to access a public WebDAV share as described in https://docs.nextcloud.com/server/20/user_manual/en/files/access_webdav.html#accessing-public-shares-over-webdav.
Steps to Reproduce
http://localhost:15755,http://localhost:15755/fetchrequest with hash of share as username:It works using plain
curl:System Information
Contents of nextcloud/data/nextcloud.log
Paste output here(No access to logs, hosted by Hetzner)
Contents of Browser Error Console
Read http://ggnome.com/wiki/Using_The_Browser_Error_Console if you are unsure what to put here