''http://localhost:3000' has been blocked by CORS policy - For external API

I don't have access to an external API but I am being blocked out by CORS. I have also enabled "Access-Control-Allow-Origin" in the Axios post config. Most answers are tailored to a local api. How do I get around this?


const auth = {
  username: "xxx",
  password: "xxx",
};

const res = await axios.get(
      `https://api.staging.CORP.dev/stuff/{my-key}/pub_id`,
      { auth },  
        {
        headers: {
          "Content-Type": "application/json",
          "Access-Control-Allow-Origin": "*",
        },
      }
    );
    const pub = res.data.map((pub) => ({ puv_id: pub.id }));
    const data = {
      address: {
        postcode: 'PostCode',
      },
      full_name: 'name',
      email: 'email',
      pub_id: pub
    };
    axios
      .post(
        "https://api.staging.CORP.dev/stuff/{public}/orders",
        data,
        { auth },
        {
          headers: {
            "Content-Type": "application/json",
            "Access-Control-Allow-Origin": "*",
          },
        }
      )
      .then((res) => console.log(res))
      .catch((err) => console.log(err.response));


Solution 1:[1]

You can try adding "proxy": "http://localhost:3000", in your package.json

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DarkForest