I would like to build a website. Due to the CORS problem I would need a proxy for all my requests. I would like to use Netlify Functions as the proxy.
Instead of writing several Netlify Functions that make requests to different servers, I would like to create a Netlify Functions that serves as a proxy and make all requests using that proxy Netlify Functions.
I’d like to know if there are some Netlify Functions sample code that serves as proxy? Thanks in advance.
If you are having CORS issues, then your URL is probably not set up to handle requests that originate from a different domain. You’ll need your URL to include an “Access-Control-Allow-Origin” header like @jen mentioned. So if you want to do the fetch directly on the client-side, you’ll need to modify your URL to include that header with a value that allows your site to access the response from it.
@Dennis Thanks for the response. I understand this is not Netlify related thus I tried to build a proxy function that allows me to get the result from the API call.
But in reality, I am fetching the information in the third-party server using a node module. I am not sure if it is possible for me to clear up the CORS issue using their npm module. Therefore the proxy method comes into my mind.