let link = https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/? key=XXXXXXXXXX&steamids=764564564575656
fetch(link)
.then(resp => {
resp.json()
})
.then(data=> {
console.log(data)
})
I am trying to develop chrome extension that gets data from specific website and sends get request to an API, I have this problem when I try to send GET request to that API website I get this error. It looks like that website blocks any external requests using extension, is there any possible way to avoid this?
I get this error:
from origin ‘https://csfloat.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
2
Answers
this is because you are trying to access
api.steampowered.com
from different originhttps://csfloat.com
, you need to tell your server to allow it to access the server resources, if you are usingNodeJS
for backend, installcors
(Cross-origin resource sharing) throughnpm install cors
and then in your server code :this way your server can be accessed and only can be accessed from
https://csfloat.com
You have to adapt your manifest file for a valid host_permissios property, so that it contains the websites you want to access.