berrnd / send-link

A simple Firefox Add-on to send links via customizable context menu entries as GET requests (mailto: is also supported).
https://addons.mozilla.org/firefox/addon/send-link
MIT License
2 stars 2 forks source link

Bug: Properly report CORS preflight request errors #2

Open barelylit opened 2 weeks ago

barelylit commented 2 weeks ago

Since the latest update, i am getting:

An error happend while executing a GET request to http://xxxxxxxxxxxxxxxxxxxxxxxx

Status: 0

Response:

The end point is a flask app, ans is returning 200 for sure, the line of code for the function end is:

return '200 - OK', 200

berrnd commented 2 weeks ago

Nothing about how GET requests are executed has changed in the latest release, just the fact that errors are now visible, before any error was just silently ignored. So are you sure the exact same GET request worked before for real?

 

the line of code for the function end is

What should "the line" exactly refer to?

  I can't really help without having a reproducible example. Personally I use this extension daily multiple times since years and it works and at the end any error is just about the receiver side of the corresponding request definition.

berrnd commented 2 weeks ago

A quick hint how to get more information on the failed request:

Ctrl + Shift + J to open the Browser Console, check if something pops up there while executing the Send Link action.

barelylit commented 2 weeks ago

Oh its still working, the data is still being processed by the receiving end perfectly, just i get a popup of this error appearing now.

Could it possibly be made as a configurable option to show errors or not?

Response comes back perfectly in a rest client API tester extension:

Screenshot 2024-11-06 142028

berrnd commented 2 weeks ago

Response comes back perfectly in a rest client API tester extension

Well, this Add-on isn't "a rest client API test extension". So something clearly goes wrong. Have you checked the Browser Console for further hints what's going on as mentioned in my previous message above?

Code ref how this Add-on checks for if the request succeeded: https://github.com/berrnd/send-link/blob/0179e1edd8399fe3f88c4dd8ff36b3f9ccb123ca/background.js#L61-L77

 

Could it possibly be made as a configurable option to show errors or not?

Of course that's technically possible. But I don't get why any error should be just ignored - exactly that was a big problem before last week.

barelylit commented 2 weeks ago

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <>. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

barelylit commented 2 weeks ago

Ive enabled CORS on the flask app, and all good now

berrnd commented 2 weeks ago

Great.

However, now that this Add-on can report errors let's track here to somehow also report problems when the CORS preflight request failed since I guess that's often a problem. Interesting though that the "real" request got through anyways for your example...