Skip to content
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

filesListFolderLongpoll() causes CORS preflight error #85

Closed
tnightingale opened this issue Nov 7, 2016 · 29 comments
Closed

filesListFolderLongpoll() causes CORS preflight error #85

tnightingale opened this issue Nov 7, 2016 · 29 comments

Comments

@tnightingale
Copy link

XMLHttpRequest cannot load https://notify.dropboxapi.com/2/files/list_folder/longpoll.
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 501.

Tested on macOS Chrome (54.0.2840.71 (64-bit)), Safari (10.0.1 (11602.2.14.0.7)) & Firefox (49.0.2).

This seems unrelated to #42 (or associated issues) because domain is notify.dropboxapi.com not api.dropboxapi.com.

Can also be reproduced with following XHR request:

var xhr = new XMLHttpRequest();
xhr.open("POST", "https://notify.dropboxapi.com/2/files/list_folder/longpoll");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify({cursor: "AAG9UMjHQxjlfNX_rOPsVO0W27HIkPlD-xBu0rETcMhuWsprxpgE-94NVr29SIgJfGlFokxPbJSuTG6ryGD01d_amqnijqi0fcXp2cdkYeq63krcuD9jKVeU4kbBNSLfXzswS-NXCJJF1IA_AUeL_h4ZKFyuJIuVRQNodUu8EOo0Vw"}));
// I assume you'll need to provide a cursor value that matches your own account

It seems it is the Content-Type "application/json" header that is triggering the CORS prefilght. The suggested Content-Type "text/plain;charset=dropbox-cors-hack" hack doesn't work as all 3 browsers I tested rewrite to "text/plain" which result in a 400 Bad request.

@greg-db
Copy link
Contributor

greg-db commented Nov 7, 2016

Thanks! We'll look into it.

@MaxwellKeeble
Copy link

I'm also having what I think is this issue - same errors as above:

OPTIONS https://notify.dropboxapi.com/2/files/list_folder/longpoll 501 (Not Implemented)
XMLHttpRequest cannot load https://notify.dropboxapi.com/2/files/list_folder/longpoll. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 501.

When I then installed "Allow-Control-Allow-Origin: *" Chrome plugin as a test, longpoll still returns:

XMLHttpRequest cannot load https://notify.dropboxapi.com/2/files/list_folder/longpoll. Response for preflight has invalid HTTP status code 501

@grazinskis
Copy link

@MaxwellK For chrome and firefox use the Fetch API.
For IE use a fetch polyfill.
For Safari use a different api method or longpoll implementation

@geyang
Copy link

geyang commented Mar 4, 2017

@grazinskis what exactly do we need to do for Safari? Thanks!

@kennellink
Copy link

kennellink commented Mar 7, 2017

This looks like it was reported four months ago and is not yet working. I am getting the same error as the OP @tnightingale and @MaxwellK above and cannot use longpoll. Am I missing something?

@kennellink
Copy link

kennellink commented Mar 7, 2017

I just got lonpoll working by hacking the .min version from distribution (since non-min does not work in a browser) to effectively change rpcRequest() to do apiRequest.type("text/plain; charset=dropbox-cors-hack") and apiRequest.send(JSON.stringify(body))

This apparently avoids the CORS preflight, thus avoiding the 501 response from the server to the preflight.

This hack also did not break anything (in my own little testing of my app).

I hope this can make it into a distribution soon (or a fix to the server accepting preflight). I'm trying really hard to get off of v1 before it's shutoff in June!

@grazinskis
Copy link

@episodeyang I have come up with a couple ways of dealing with it:

  1. The first method described here (number 1)
  2. Periodically call filesListFolderContinue() with your latest cursor and check how many changes it reports.

It's ugly though. Amazing for how long this issue is still relevant. Let's hope the fix of @kennellink works, doesn't break anything else and can make it to distribution.

@greg-db
Copy link
Contributor

greg-db commented Mar 7, 2017

Thanks for following up, everyone. This issue is still open with the team on our side. I'll follow up here once we have an update.

@kennellink
Copy link

Thanks @episodeyang. My hack does not work in Firefox and perhaps others since they rewrite the content-type. Works in IE.

@pran1990
Copy link
Contributor

pran1990 commented Mar 8, 2017

Hey @kennellink and others, we are in the midst of a backend rewrite that will fix this for free, but I'm unable to give you an eta yet. Give me a couple of days for an ETA.

Thanks a lot for the patience, and thanks for reporting.

@kennellink
Copy link

Thanks @pran1990, I appreciate the help! Can I look forward to having a working filesListFolderLongpoll() (with some time to test) before the June deadline to be off API v1?

@greg-db
Copy link
Contributor

greg-db commented Mar 29, 2017

I don't have a timeline for a fix right now. I'll check in with the team again.

@geyang
Copy link

geyang commented Mar 30, 2017

@greg-db Thanks! :)

@kennellink
Copy link

kennellink commented Apr 10, 2017

Hi everyone. I appreciate the work you're doing here. We have a deadline, however, from Dropbox to be off API v1 by June 28 and I am in dire need of filesListFolderLongpoll() to work before then. Do you know if Dropbox will extend that deadline or if Longpoll is expected before then? I'm sorry to push, but we have an app in production that our customers rely on and I need a plan to provide uninterrupted service.

I'm afraid the active polling technique would trigger throttling, so I don't have an alternative at this point.

@greg-db
Copy link
Contributor

greg-db commented Apr 11, 2017

@kennellink Thanks for following up, and apologies for the delay. Work on this is ongoing, but it requires some infrastructure changes to do right. I can't offer a guaranteed timeline, but we do expect this to be done this month, well ahead of the v1 retirement.

@geyang
Copy link

geyang commented Apr 11, 2017

Thanks @greg-db ! It's really good to hear.

@kennellink
Copy link

Thanks @greg-db that sounds great! Best wishes.

@kennellink
Copy link

Hey @greg-db and @pran1990 , I hope all is well. I just received a reminder from Dropbox that the v1 API is going away soon. I have about a month, which is not long enough to completely rewrite to another SDK. Is this SDK going to have longPoll working in the near near future so I can finish testing and finalize the upgrade? If not, do you know who I would contact at Dropbox to extend access to v1 API or if they'll even entertain the idea since I've been depending on this SDK working?

@pran1990
Copy link
Contributor

pran1990 commented May 24, 2017 via email

@greg-db
Copy link
Contributor

greg-db commented May 24, 2017

We are reviewing requests for extensions to API v1 access though. If you'd like an extension for access to API v1, please open an API ticket:

https://www.dropbox.com/developers/contact

Please include:

  • The app key(s) for the app(s) you need an extension for.
  • The reason(s) for the extension.
  • How long of an extension you're asking for.

@good-lly
Copy link

good-lly commented Jun 6, 2017

Longpoll still 501 (Not Implemented) - any ETA please?
Would be really nice with some advance against the v1 deprecation ...

@greg-db
Copy link
Contributor

greg-db commented Jun 6, 2017

I don't have an update on this yet unfortunately. We'll follow up here once we do.

@prusnak
Copy link

prusnak commented Jun 29, 2017

This is really critical for our applications. Glad that you postponed the depreciation date, but we would love to see this implemented in new API.

@pran1990
Copy link
Contributor

pran1990 commented Jun 29, 2017 via email

@BobDickinson
Copy link
Contributor

So filesListFolderLongPoll was reported broken 9 months ago, is not fixed, and has no fix in sight. There is no unit test for it, so it's not clear if it was ever tested or if it ever worked. Am I missing something? As someone new to this SDK and assuming it was generally stable, that's pretty disconcerting.

@greg-db
Copy link
Contributor

greg-db commented Aug 21, 2017

Thanks for the feedback @BobDickinson . We are still working on the infrastructure change, but it has taken longer than anticipated. We'll follow up here once it's done. Apologies for the trouble!

@good-lly
Copy link

good-lly commented Sep 4, 2017

API v1 cutoff date until September 28th, 2017 ???
great, just still missing a few basic functions! Please, fix it at least a few weeks before deadline, we need to test our apps as well before cutoff.

@greg-db
Copy link
Contributor

greg-db commented Sep 5, 2017

Work on this is still in progress. If you need an extension for access to API v1 please refer to this comment for instructions for requesting one.

@greg-db
Copy link
Contributor

greg-db commented Sep 21, 2017

This should be working now. Please let us know if you're still seeing any issues.

@greg-db greg-db closed this as completed Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants