Cord Sring - Error in Firefox browser

0

I've ever happened to them that when they open their website in google chrome, internet explore works all the CORD but when I open it with Mozilla Firefox I get this error:

  

Request from another blocked source: the same source policy prevents reading the remote resource in link (reason: token 'content- type 'not present in the CORS header' Access-Control-Allow-Headers' of the preflight CORS channel).

Someone can tell me what to do, what else is the firefox browser that my browser blocks it.

    
asked by eduwin30 20.04.2018 в 18:22
source

1 answer

0

Good Friend had that same problem, in all browsers well by in firefox no!

The solution is to manually add the headers you are using on the server, I'm using Spring boot with jersey and the filter is like this:

  

@Provider public class CorsResponseFilter implements   ContainerResponseFilter {

private final static String ALLOWED_METHODS = "GET, POST, PUT, DELETE, OPTIONS, HEAD";
private final static int MAX_AGE = 42 * 60 * 60;

@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
    final MultivaluedMap<String, Object> headers = responseContext.getHeaders();
    headers.add("Access-Control-Allow-Origin", "*");
    headers.add("Access-Control-Allow-Headers", "Authorization, Client, Secret, Content-Type, *");
    headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
    headers.add("Access-Control-Allow-Credentials", "true");
    headers.add("Access-Control-Max-Age", MAX_AGE);
} }
    
answered by 25.07.2018 в 00:51