CORS error when using Axios

We are trying to create a web app using React and the Axios library. However we are running into the CORS policy error even with the headers we included:

const headers = {
      'Content-Type': 'application/json',
      'Access-Control-Allow-Origin' : '*',
  'Access-Control-Allow-Methods':'GET,PUT,POST,DELETE,PATCH,OPTIONS',
      'api-key': '...'
      
    };
  
    for (let i = 0; i < users.length; i++) {
      const userData = {
        email: users[i].email
      };
  
      try {
        const response = await axios.post(
          "<url>,
          userData,
          { headers: headers } // Correct way to pass headers
        );
        console.log(response.status, response.data);
      } catch (error) {
        console.error('Error registering user:', error);
      }
    }
  };

We’ve gone the App Settings to add http://localhost:port, but it still has the same issue. Not sure where to go from here.