ajax - net::ERR_CONNECTION_RESET in axios while requesting from a Dropwizard server -


i have dropwizard server , universal app using react , redux. when trying post call using axios universal app. getting net::err_connection_reset error.

i have set cors in dropwizard as:

    filterregistration.dynamic filter = environment.servlets().addfilter("cors",crossoriginfilter.class);     filter.addmappingforurlpatterns(enumset.allof(dispatchertype.class), true, "/*");     filter.setinitparameter(crossoriginfilter.allowed_methods_param, "get,put,post,delete,options");     filter.setinitparameter(crossoriginfilter.allowed_origins_param, "*");     filter.setinitparameter(crossoriginfilter.access_control_allow_origin_header, "*");     filter.setinitparameter(crossoriginfilter.allowed_headers_param, "*"); 

i have following debug log jetty : debug [2016-03-07 05:42:04,189] org.eclipse.jetty.servlets.crossoriginfilter: cross-origin filter configuration: allowedorigins = *, allowedmethods = get,put,post,delete,options, allowedheaders = *, preflightmaxage = 1800, allowcredentials = true,exposedheaders = ,chainpreflight = true

the request axios this

request             .post('http://localhost:8080/auth/register',{                  username: 'foo',                  password: 'bar'              })             .then((res) => {                 console.log(res);             })             .catch((err) => console.log(err)) 

chrome network info

also works if use simple xmlhttprequest console

 var xhttp = new xmlhttprequest();   xhttp.onreadystatechange = function() {     if (xhttp.readystate == 4 && xhttp.status == 200) {       console.log("ok");     }   };   xhttp.open("post", "http://localhost:8080/auth/register", true);   xhttp.send(json.stringify({            username: 'foo',            password: 'bar         })); 


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -