-
Notifications
You must be signed in to change notification settings - Fork 0
Home
private static final String HEADER_ACA_ORIGIN = "Access-Control-Allow-Origin"; private static final String HEADER_ACA_CREDENTIALS = "Access-Control-Allow-Credentials"; private static final String HEADER_ACA_METHODS = "Access-Control-Allow-Methods"; private static final String HEADER_ACA_HEADERS = "Access-Control-Allow-Headers"; private static final String HEADER_CONTENT_TYPE = "Content-Type"; public static final String HEADER_API_KEY = "Harmonie-SM-API-Key"; public static final String HEADER_AUTH = "Harmonie-Authentication";
@Override public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
MultivaluedMap<String, Object> headers = containerResponseContext.getHeaders();
headers.add(HEADER_ACA_ORIGIN, "*");
headers.add(HEADER_ACA_CREDENTIALS, "true");
headers.addAll(HEADER_ACA_METHODS, HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.OPTIONS, HttpMethod.HEAD);
@OPTIONS @Path("/getsample") public Response getOptions() { return Response.ok() .header("Access-Control-Allow-Origin", "*") .header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS") .header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build(); }
dans le web services
If non of this work, try to exchange the "" provided for "Access-Control-Allow-Origin" header with your custom domain where you access this resource. I.g. If you call this from http://localhost::8080 use something like this ("Access-Control-Allow-Origin", "http://localhost:8080") instead of asterisk ""