hoppscotch / hoppscotch-extension

🧩 Browser extensions to provide more capabilities to https://hoppscotch.io
https://hoppscotch.io
MIT License
254 stars 93 forks source link

CORS error when using extension outside of the official hopscotch instance #184

Open mklilley opened 1 year ago

mklilley commented 1 year ago

Hi there.

I'm a bit confused about how the browser extension is supposed to work.

I installed the extension in brave and was then able to send requests to previously CORS blocked sites from https://hoppscotch.io/. I was able to do this by switching on the interceptor in the settings - everything was super clear and easy.

I wasn't however sure what the Add new origin thing in the extension was supposed to do. In the README of this repo is says:

If you want to use the extension anywhere outside the official Hoppscotch instance you may want to add the domain to the extension's origin list. You can access the origin list by clicking on the extension icon on your browser toolbar.

I took this to mean that if I add e.g. http://localhost:3000 then if I'm on http://localhost:3000 and I make a request to e.g. https://www.fruityvice.com/ then I won't have any CORS issues because hopscotch extension will make the request to https://www.fruityvice.com/ for me and add all the necessary CORS stuff. I was not able to make it work though. I still got CORS issues doing this. I also wondered whether instead I should add https://www.fruityvice.com/ as a new origin. I tried it and this also didn't work - I still got CORS errors when requesting https://www.fruityvice.com/ from http://localhost:3000

Perhaps I'm misunderstanding how to use the extension anywhere outside the official Hoppscotch instance.

Could someone offer some guidance please.

Thanks

kwmiebach commented 1 year ago

Adding the url of the hoppscotch instance from the browser worked for me. Just copy paste it from the address bar from the hoppscotch instance where you are doing the requests. Remeber to include the correct protocol (http or https) and also the port.

After adding the url in the browser extension I hard reloaded the hoppscotch page with ctrl-klick on the reload button of the browser. This worked for me in firefox and google chrome on linux but not in edge (also linux).

I did not try this with IPs in the url, only with domain names like http://localhost:3000 or http://myserver.localdomain:3000