skip to Main Content
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


  1. this is because you are trying to access api.steampowered.com from different origin https://csfloat.com, you need to tell your server to allow it to access the server resources, if you are using NodeJS for backend, install cors (Cross-origin resource sharing) through npm install cors and then in your server code :

    const cors = require("cors");
    
    app.use(cors({ origin: "https://csfloat.com/" }));
    
    

    this way your server can be accessed and only can be accessed from https://csfloat.com

    Login or Signup to reply.
  2. You have to adapt your manifest file for a valid host_permissios property, so that it contains the websites you want to access.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search