Access-Control-Allow-Origin error in ember.js

Asked By: Anonymous

I’m using ember.js and it is throwing me this error:

XMLHttpRequest cannot load Response
to preflight request doesn’t pass access control check: No
‘Access-Control-Allow-Origin’ header is present on the requested
resource. Origin ‘http://localhost:4200‘ is therefore not allowed

On my server side, I have placed codes to print out a log for GET, POST and PUT calls. It does NOT print out anything. Therefore, I think the client-side never made any requests to the server. (However, access ‘‘ manually does indeed invoked the log on the GET method.)

The server-side is already coded to return the Access-Control-Allow-Origin and it works for other methods.

So, what is my problem?

And just for for the record, the server side in Java is:

responseBuilder.header("Access-Control-Allow-Origin", "http://localhost:4200");
responseBuilder.header("Access-Control-Allow-Headers", "origin, content-type, accept, authorization, auth-token");
responseBuilder.header("Access-Control-Allow-Credentials", "true");
responseBuilder.header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");

and in my ember.js config/environment.js I have:

ENV['contentSecurityPolicy'] = {
        'default-src': "*"


Answered By: Anonymous


private static void setAccessControlAllowOrigin(ServletContextHandler context) {
        FilterHolder holder = new FilterHolder(CrossOriginFilter.class);
        holder.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
        holder.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "");
        holder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,POST,PUT,HEAD");
        holder.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin");
        FilterMapping fm = new FilterMapping();
        context.getServletHandler().addFilter(holder, fm);
techinplanet staff

techinplanet staff

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno