To solve CORS error while fetching an external API, you can either move the request to a server you control or use a CORS proxy.
Moving the request to your backend server: Set up an endpoint on your backend server that makes the request to the external API and then serve the response to your frontend.
Using a CORS proxy: Forward the browser request to a CORS proxy that fetches the external API, adds the missing Access-Control-Allow-Origin header, and returns the response to the browser.
In both approaches, the solution bypasses the CORS restrictions by ensuring the response from the external API includes the necessary Access-Control-Allow-Origin header.