hoppscotch / hoppscotch-extension

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

Cant set "origin" header with chrome extention #166

Open Tineshnehete opened 2 years ago

Tineshnehete commented 2 years ago

Issue

Due to security checks chrom blocks setting custom the headers. So we can set custom origin header for Api request.

Reason

We are using axios for proxying the request , but as axios uses xhr to make http request chrome blocks or restrict to set custome origin header .

Fix

To overcome we can update chrome extention and switch to https://developer.chrome.com/docs/extensions/reference/webRequest/ as far as i explored i can find any soln for axios proxy

AndrewBastin commented 1 year ago

@Tineshnehete I have looked into the webRequest API for implementing this, but I am pretty sure we have an issue here.

From the statement in the WebRequest API explainer link you provided:

To intercept a sub-resource request, the extension needs to have access to both the requested URL and its initiator.

This is a problem for us as we cannot expect us to have access to the "requested URL" always. Hence, the browser will not let the interception to take place, I would love to be proven wrong though, because if this approach works, this can actually help with a lot of things for Hoppscotch.