diff --git a/src/main/java/com/pixels/CorsFilter.java b/src/main/java/com/pixels/CorsFilter.java new file mode 100644 index 0000000..7e7c713 --- /dev/null +++ b/src/main/java/com/pixels/CorsFilter.java @@ -0,0 +1,27 @@ +package com.pixels; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.ext.Provider; + +@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"); + } +}