You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My project need to create directories on webdav server and the createDirectory do not work with recursive option because of the CORS preflight request.
For example, a recursive call to create a path /a/b/c, multiple stat requests are made to defect if the directory /a and /a/b are exists.
@bitrevo You're right, collections should be queried with a trailing slash. Several sources I've checked (no RFC that I found, yet) seem to suggest to do so to remove ambiguity and that beyond that the server will return 301 to normalise paths as it chooses.
This needs to be fixed, yes, but you should also review your CORS configuration. A 301 should not result in a CORS error, and it sounds like the service is not correctly configured for web-based access.
@perry-mitchell Thanks for the information. I found the issue caused by my Apache webdav backend.
The browser will send OPTIONS request to the new directory path for cors preflight checking, and the backend should response 200 even if the target directory not exists. The default setting of Apache will send out response 301 if accessing a directory path without the ending slash. (/a to /a/)
My project need to create directories on webdav server and the
createDirectory
do not work withrecursive
option because of the CORS preflight request.For example, a recursive call to create a path
/a/b/c
, multiplestat
requests are made to defect if the directory/a
and/a/b
are exists.The library send out the request with the path
/a
instead of/a/
which caused webdav server responses301 Moved Permanently
, it is expected behavior regarding the MDN doc (https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSExternalRedirectNotAllowed).Is it make sense to fix the
createDirectory
API call by add the ending slash to thestat
request to avoid the CORS error?The text was updated successfully, but these errors were encountered: