Sample code:
public class SimpleCorsResponseFilter implements ContainerResponseFilter {
@Override
public ContainerResponse filter(ContainerRequest req, ContainerResponse resp) {
String requestOrigin = req.getHeaderValue("Origin");
if (requestOrigin == null) {
return resp;
}
else{
MultivaluedMap<String, Object> headers = resp.getHttpHeaders();
headers.add("Access-Control-Allow-Origin", requestOrigin);
headers.add("Access-Control-Allow-Credentials", "true");
headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
headers.add("Access-Control-Allow-Headers", "Content-Type");
return resp;
}
}
}
|
References (for the wildcard issue):
No comments:
Post a Comment