1
votes

I just finished setting up a load balancer with a few backend servers serving an API, I tried to hit it via https and discovered I need to set the CORS headers

but for the life of me no Googling has turned up anything. My setup roughly is a main service (actually hosted in aws for now) at https://www.example.com, then the api hosted at https://api.example.com on Google Cloud.

How can I set the load balancer COS such that I can hit api.example.com from the client side js on www.example.com

Is there even a way?

1

1 Answers

2
votes

your backend server, at https://api.example.com should set the CORS headers. it's a browser security feature, the browser is at https://example.com but makes AJAX requests to a different domain.

set the headers from the backend application, it is not related to the load balancer (unless it re-writes headers).

read more about CORS - http://restlet.com/company/blog/2015/12/15/understanding-and-using-cors/