CORS (cross-origin resource sharing) lets a server declare which browser-based clients may access its resources. Browsers commonly block a JavaScript interface hosted on a different host or port from consuming an API; CORS response headers provide the permitted exception. section 7.1.1
In Spring, apply CORS with @CrossOrigin. Set origins to the allowed client origin, such as http://tacocloud:8080, or provide an array when multiple origins need access. section 7.1.1
Allow a separate Taco Cloud client
@RestController @RequestMapping(path="/api/tacos", produces="application/json") @CrossOrigin(origins={"http://tacocloud:8080", "http://tacocloud.com"}) public class TacoController { ... } This controller permits browser clients from the two listed origins to consume the JSON API.




