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

[feature]: Better error message for first-time-users: No 'Access-Control-Allow-Origin' header is present #1376

Open
guettli opened this issue Dec 10, 2020 · 13 comments
Labels
discussion Talking over coding good first issue Good for newcomers

Comments

@guettli
Copy link

guettli commented Dec 10, 2020

Is your feature request related to a problem? Please describe.

I try to execute my first GET request and get this result:

image

I think the first-time-user experience could get improved here.

The hint to F12 vanishes soon, and I think accessing the error message via F12 is not a nice solution.

It would be nice, if the software could tell me directly what went wrong. Then maybe some explanation, and
a way how to work around this.

@liyasthomas
Copy link
Member

Makes sense. Toast is too small to be noticed. I appreciate if you can suggest a better way to enhance error state ux?

@liyasthomas liyasthomas added the discussion Talking over coding label Dec 10, 2020
@AndrewBastin
Copy link
Member

Umm, we could improve the error UX. But the problem we are facing is that browsers don't let the full details of the network error to be given to the scripts. As far as the script is concerned, we are only given a "Network Error" message and it is pretty generic and is thrown for every network related issue, not only the one you mentioned as an example.

Since we can't exactly know what went wrong, we really can't suggest anything on how to fix it.

@NBTX
Copy link
Contributor

NBTX commented Dec 11, 2020

This isn't a general solution for any CORS policy - but it would allow us to figure out perhaps if we need to show a full-page dialog prompting them to install the browser extension or enable the proxy.

We could perhaps set up an API route that works in every way except by having an Access-Control-Allow-Origin policy to a random domain. That way we could test by first requesting a 204 to some domain (to establish that the device is connected to the internet) and then make a request to our CORS route - if it succeeds, proxy or extension is enabled, if it fails, the error must be due to CORS hence we can show the full-page dialog.

@guettli
Copy link
Author

guettli commented Dec 15, 2020

@AndrewBastin this is new to me. The script just gets "NetworkError" without a message? Hmm let's focus on this. How could this be changed? Of course this is not an issue of hoppscotch any more, but on the other hand we could make life easier for thousand developers. Who could help here?

@AndrewBastin
Copy link
Member

I don't think we have any other ways to get it from a browser request stand point.

The solution provided by @NBTX sounds great. But I don't really encourage it because of security concerns and the user not knowing that request is being ran on the background through a proxy.

@AndrewBastin
Copy link
Member

@satyam-52 I don't know how this fits into the conversation here exactly.

Hoppscotch already has a built in proxy that circumvents this issue. You can enable it in the Settings page.

@satyam-52
Copy link

@AndrewBastin Just re-read the problem, I just misinterpreted. Will delete my comment :)

@KartikSoneji
Copy link

@AndrewBastin

because of security concerns and the user not knowing that request is being ran on the background through a proxy.

Hmm? How is this any different from running similar network requests (google analytics, feature tracking)?
If the request is being run through a proxy, it is because the user (or someone on their behalf) explicitly enabled it.

I think adding a route like /connectivity-check/?cors=true to proxyscotch should allow checking both for network connectivity and if CORS is blocked.
As for mixed content, checking requestUrl.protocol == window.location.protocol should cover most cases.

Maybe related: #2248

@liyasthomas liyasthomas changed the title Better error message for first-time-users: No 'Access-Control-Allow-Origin' header is present [feature]: Better error message for first-time-users: No 'Access-Control-Allow-Origin' header is present Oct 2, 2022
@imskr
Copy link

imskr commented Oct 2, 2022

Can I work on this?

@liyasthomas
Copy link
Member

Hi @imskr, feel free to pick up this feature. Do let us know if you need any help.

@varun-s22
Copy link

Hi @liyasthomas, is this still open?.. can i take it?
also how are we planning to show the message on the client side?
do we show some popup notifications (like Toast, which i read above)?

@Amit-Morade
Copy link

can I work on this?

@VineeTagarwaL-code
Copy link

Assign me please , i want to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Talking over coding good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

10 participants