feat: ajout d'un truc CORS ?
This commit is contained in:
parent
9f97f39add
commit
690309b809
27
src/main/java/com/pixels/CorsFilter.java
Normal file
27
src/main/java/com/pixels/CorsFilter.java
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue