Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3619

Is it usual in web development to route third party requests via our backend? [closed]

$
0
0

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.


Viewing all articles
Browse latest Browse all 3619

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>