Open harshdamaniahd opened 6 years ago
CORS Anywhere offers a proxy for cross-origin requests. It does intentionally not allow direct requests, e.g. when you open the above URL in the location bar.
To test whether it works, send a cross-origin request with XMLHttpRequest
/ fetch
or any of your favorite AJAX libraries. If you want to initiate a request from the same origin, set the X-Requested-With
request header to satisfy the requirement.
I tried in IE console, i am getting error
fetch("http://localhost:8080/http://posthuset.eurest.no/dagens-meny/?day=mandag") .then((res) => { return res.text(); }).catch((error)=>{ debugger; console.log(error); }) .then((data) => { console.log(data); })
Missing required request header. Must specify one of: origin,x-requested-with
What is the domain from where you are testing the above code? It must be different from http://localhost:8080/
to be a cross-origin request (for example, try http://127.0.0.1:8080/
).
It is working in chrome but not working in IE. I tried using both localhost and http://127.0.0.1:8080/.
By "IE", do you mean Internet Explorer or Edge? Your example with fetch
suggests that you are probably using Edge (because IE does not support fetch
). If you use a polyfill, then be aware that IE9 and earlier does not properly support CORS.
You might be affected by https://stackoverflow.com/questions/20784209/internet-explorer-11-does-not-add-the-origin-header-on-a-cors-request
In that case, a work-around is to set the X-Requested-With
header (e.g via the headers
parameter in fetch
).
Its not working in edge as well as IE in edge it gives the following error : SEC7111: HTTPS security is compromised by http://127.0.0.1:8080
I change the code by adding X-Requested-With , but it is still not working
fetch("http://127.0.0.1:8080/http://posthuset.eurest.no/dagens-meny/?day=mandag",{
headers: new Headers({
'X-Requested-With': 'XMLHttpRequest'
})
})
.then((res) => {
return res.text();
}).catch((error)=>{
debugger;
console.log(error);
})
.then((data) => {
console.log(data);
})
Also when i run node server it shows me
PS E:\cors-anywhere-master> node server Running CORS Anywhere on 0.0.0.0:8080
That looks like a mixed content warning. Try testing from http.
you mean the site in which i am running the code is https and not http.
For example my site is : https://ten.abc.com and in this site I am executing the Fetch Api code
I tried simple google.com as well it doesn't work. When i try running it in browser , it gives me the below
In chrome i need to enable this : Load unsafe scripts
I have taken this project locally and run node
PS E:\cors-anywhere-master> node server Running CORS Anywhere on 0.0.0.0:8080
Then when i try to access the site http://localhost:8080/https://posthuset.eurest.no/dagens-meny/?day=mandag I get error Missing required request header. Must specify one of: origin,x-requested-with