Advertisement
andersonalmada

Untitled

Jul 18th, 2022
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package mandacaru4.filter;
  2.  
  3. import java.io.IOException;
  4.  
  5. import jakarta.ws.rs.container.ContainerRequestContext;
  6. import jakarta.ws.rs.container.ContainerResponseContext;
  7. import jakarta.ws.rs.container.ContainerResponseFilter;
  8. import jakarta.ws.rs.ext.Provider;
  9.  
  10. @Provider
  11. public class CorsFilter implements ContainerResponseFilter {
  12.  
  13.     @Override
  14.     public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
  15.             throws IOException {
  16.         responseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
  17.         responseContext.getHeaders().add("Access-Control-Allow-Headers", "content-type");
  18.         responseContext.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement