Spring Boot でAPIなどを作っていて、他サイトからアクセスさせると、
Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
が発生する。
これを回避させるためにCORSを制御する。
@CrossOrigin(origins = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE})
public class XxxxxxController {
@CrossOrigin アノテーションで許可したいorigin、メソッドなどを設定する。