there is a concept I think I am not understanding in web development. So I am using NextJS to code a web application which uses third party APIs like GoAPI.Simplified my problem is:When I click on a button in the front end I am trying to make a request to the third party API. Now this will fail due to following error:
Access to fetch at '' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Now as a workaround I used to do it like this:Button is clicked -> Frontend send a request to my backend (through the API routes) -> From the backend I will send a request to the endpoint
However, this is lots of code and I am also not sure about it's impact on performance or if this is the common practice? How is it usually done?
Thanks.