我正在使用Spring 5路由器功能构建一个Web应用程序休息控制器来映射请求 .
@RestController
public class AdminRest {
public RouterFunction<ServerResponse> route() {
return RouterFunctions
.route(RequestPredicates.GET("/admin/organizations"), this::getOrganizations);
}
}
让Angular 4项目充当其余控制器的消费者 .
public getOrganizations(): Observable<OrganizationsList> {
return this.http.get(this.getOrganizationsUrl)
.map((res: Response) => res.json())
.catch((error: any) => Observable.throw(error.json().error || 'Server error'));
}
哪个返回此错误
XMLHttpRequest无法加载http:// ip:port / admin / organizations . 请求的资源上不存在“Access-Control-Allow-Origin”标头 . 因此不允许来源'http:// localhost:3000'访问 . 响应的HTTP状态代码为500.}
如何在Spring 5路由器功能中允许CORS?
1 回答
你可以注释为
有关更多信息,请参阅Spring CORS documentation