angular - Tomcat 7 server is not sending CORS headers -
i writing angular 4 application makes authenticated connection tomcat 7 server. webapp on tomcat server has rest api. have local copy of server on 1 of machines, using request url this:
http://xyz.local:8080/poolparty/api/projects i using safari request , if check disable cross-origin restrictions menu item json package returned , can display in browser. if don't check menu item error:
failed load resource: preflight response not successful i have checked cors filter configuration in server, , looks this:
<filter> <filter-name>corsfilter</filter-name> <filter-class>org.apache.catalina.filters.corsfilter</filter-class> <init-param> <param-name>cors.allowed.origins</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.allowed.methods</param-name> <param-value>get,post,head,options,put</param-value> </init-param> </filter> <filter-mapping> <filter-name>corsfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> which think correct other cases i've seen here , on other sites.
my angular request looks this:
private sendrequest(verb: requestmethod, url: string, body?: product): observable<product> { let headers = new headers(); headers.set("withcredentials", "true"); headers.set("authorization", "basic ***********"); headers.set("access-control-allow-origin", "*"); headers.set("access-control-allow-headers", "origin, x-requested-with, content-type, accept"); headers.set("content-type", "text/plain"); return this.http.request(new request({ method: verb, url: url, body: body, headers: headers })).map(response => response.json()); } so have couple of questions:
- what else have in configuring tomcat server send cors headers?
- am doing right things in request i'm sending?
update on thursday 24 august:
here headers , responses in web inspector network window (safari) when select row options method:
request & response: ==================== method: options cached: no status: ___ code: ___ encoded: ___ decoded: ___ compressed: no request headers: ================ name value user-agent mozilla/5.0 (macintosh; intel mac os x 10_12_5) applewebkit/603.2.4 (khtml, gecko) version/10.1.1 safari/603.2.4 cache-control max-age=0 referer http://localhost:4200/ origin http://localhost:4200 access-control-request-method access-control-request-headers authorization accept */* response headers no response headers i've attached couple of screenshots. first shows request , response. second shows "preflight" error messages console i've mentioned above.
error messages logged preflight:


Comments
Post a Comment