Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

jakarta allow cross origins

@Provider
public class CorsFilter implements ContainerResponseFilter {

    @Override
    public void filter(ContainerRequestContext requestContext, 
      ContainerResponseContext responseContext) throws IOException {
          responseContext.getHeaders().add(
            "Access-Control-Allow-Origin", "*");
          responseContext.getHeaders().add(
            "Access-Control-Allow-Credentials", "true");
          responseContext.getHeaders().add(
           "Access-Control-Allow-Headers",
           "origin, content-type, accept, authorization");
          responseContext.getHeaders().add(
            "Access-Control-Allow-Methods", 
            "GET, POST, PUT, DELETE, OPTIONS, HEAD");
    }
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #jakarta #cross #origins
ADD COMMENT
Topic
Name
3+8 =