Cors error for local host in javascript

I have an error Access to fetch at ‘https://api.company-information.service.gov.uk/search?q=mic’ from origin ‘"ht"tp://localhost:3000’ 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.

in this code
`
const apiKey = ‘53e8a922-d8a3-4d6e-9127-xxxxx’;
const apiUrl = ‘ht"tps://api.company-information.service.gov.uk/search’;

export const searchCompanies = async (query: string) => {
const headers = new Headers();

headers.set(‘Authorization’, 'Basic ’ + btoa(apiKey + “:” + “”))

try {
const response = await fetch(${apiUrl}?q=${query}, {
headers: headers,
mode: ‘cors’,
});
console.log('response :>> ', response);

if (!response.ok) {
  throw new Error(`HTTP error! Status: ${response.status}`);
}

const data = await response.json();
console.log(data); // Output the search results
return data.items;

} catch (error) {
console.error(‘Error:’, error);
}
};
`

1 Like