CORS error when calling api client side
Answered
Crazy ant posted this in #help-forum
Crazy antOP
I'm calling this https://stageapi.trendyol.com/stagesapigw API which doesn't belong to me. Note: your IP should be included in the whitelist to use it.
I tried to call it server side it worked just fine but when I tried calling it client-side I got
I tried to call it server side it worked just fine but when I tried calling it client-side I got
Access to XMLHttpRequest at 'https://stageapi.trendyol.com/stagesapigw/product-categories' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. error. I tried adding access-control-allow-origin to the request but it didn't work. Is it because the client-side has different IP? (I assume this is how it works).Answered by fuma
access-control-allow-origin is a header sent from the server which indicates the allowed origin. If you got this error, it means they don't allow requests sent from
localhost or your domain. CORS errors only happen on the client side, that's why you won't get any errors when fetching it from the server.1 Reply
access-control-allow-origin is a header sent from the server which indicates the allowed origin. If you got this error, it means they don't allow requests sent from
localhost or your domain. CORS errors only happen on the client side, that's why you won't get any errors when fetching it from the server.Answer