-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cors error on file sharing apis (OCS) #89
Comments
I'll take a look asap. I've got it working using the webdav picker. Let me check and compare requests and responses. |
I couldn't reproduce... Just inspecting a little and as I said I have it working using webdav-filepicker (patching a file to change the share endpoint url to the webapppassord one).
This call must return
(Where the relevant ones are the Access-control ones) After that a regular post request to If you paste the options request headers and repsonse maybe I could help a little more... |
@aleixq yes i copied your fetch request in my code its status code is 200 for options request and header of response is exactly you said
mention that this is error in console:
|
Could you please paste using "add collapsible content" button in this editor the request and response headers of OPTIONS and POST ? you could use next as template: OPTIONS headers request
OPTIONS headers response
POST headers request
POST headers response
---- END of TEMPLATE ---- These headers will help a lot determining if the origins check is made as it should (logics are in https://github.com/digital-blueprint/webapppassword/pull/61/files#diff-e9996f62a46f389c1d8031d1020d33d4a97c47db07606c0ad730eb7d0b88e7de if you want to help debugging it) About the issue itself, Is 'http://localhost:8080' among the allowed origins? |
OPTIONS headers request
OPTIONS headers response
POST headers request
POST headers response
i added to allow origins 'http://localhost:8080' like webdav section |
Why did you comment the OCS-APIRequest header in your axios post? Could you please check setting this to true. Let's test but i think this is the cause. Despite it is not a regular OCS endpoint request it needs these set to true as this method is inherited from an ocs endpoint. And as documentation says in https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html :
|
@aleixq i tested it previously so i comment that now i checked that with header again but still cors error and nothing changes . post request headersPOST /apps/webapppassword/api/v1/shares HTTP/1.1
post response headersHTTP/1.1 200 OK
|
Well. Let's check another thing. Did you test with basic auth rather than bearer ? |
@aleixq i tested it and not worked too when everything is ok its error is cors error. i think this can be helpful when i enable cors extension on chrome it works correctly but the problem is when i enable cors extension, web dav apis get cors error and and no longer works. |
I don't know if i am understanding... Could you use punctuation? So the problem appears when using a chrome extension? |
@aleixq no no . im working with webdav apis and share apis without enabling cors extension . with disable cors extension webdav apis works correctly and share apis get cors error but if you enable cors extension, share apis will works but webdav apis get cors error. |
@aleixq if we comment the section of header set in |
Let me create a simple manual test case to evaluate if there's something wrong(asap). What is true is that I have it working fine with nextcloud-webdav-filepicker both webdav and share api. While test is not made you can check it out with this filepicker (you must change the endpoint url to point to webapppassword filesharing endpoint url) |
@aleixq im using webapppassword filesharing endpoint as code already posted here and im looking at nextcloud-webdav-filepicker codes and to be honest i didnt find any useful tip . now i added these headers temporary in first line of ShareApiController and now works but as you know this way is not ok
|
Hi again, I have created some manual tests in https://gitlab.com/communia/nc-webapppassword-share-test . They are ran as it should... Could you test to see if fails in your case ? note that I am using fetch api so not axios directly. The readme.md explains everything. More users and environments tests are welcome to find errors... I see another issue but not in our domain: a thing that must be reviewed is that share api call to native files_sharing endpoint is not allowed but is executed and share is created... despite cors origin failing... So share is created but no response text can be used in script because of cors. |
Explain the Problem
i have problem with using share api . doument tells we should use /apps/webapppassword/api/v1/shares instead /ocs/v2.php/apps/files_sharing/api/v1/shares as far as i found out. when i use /apps/webapppassword/api/v1/shares OPTIONS request is ok but i got cors error on request itself (POST) and when i use /ocs/v2.php/apps/files_sharing/api/v1/shares i get method not allowed error on OPTIONS request.
currently im using webapppassword and i have no problem with webdav apis
im using these apis in same project . how to call share apis without cors error
Steps to Reproduce
this is my axios call
System Information
Contents of nextcloud/data/nextcloud.log
nothing adds in log
Contents of Browser Error Console
Access to XMLHttpRequest at 'http://nextcloud_proxy_backend.develop/apps/webapppassword/api/v1/shares' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The text was updated successfully, but these errors were encountered: