angularjs - Response for preflight has invalid HTTP status code 405 on Angular Js1 and Webapi 2 -
error:
options http://localhost:8080//api/home/gettext 405 (method not allowed) http://localhost:8080//api/home/gettext. response preflight has invalid http status code 405 angular.js:14362 error: error getting home/gettext data database! headers:
response headers:
access-control-allow-credentials:false access-control-allow-headers:gid,origin, x-requested-with, content-type, accept, authorization access-control-allow-methods:get, post, put, delete, options access-control-allow-origin:* allow:get content-length:76 content-type:application/json; charset=utf-8 date:fri, 28 jul 2017 10:30:06 gmt server:microsoft-iis/10.0 x-powered-by:asp.net
request headers:
accept:*/* accept-encoding:gzip, deflate, br accept-language:en-us,en;q=0.8 access-control-request-headers:authorization,gid access-control-request-method:get cache-control:no-cache connection:keep-alive host:localhost:8080 origin:http://evil.com/ pragma:no-cache referer:http://localhost:1852/ user-agent:mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, gecko) chrome/59.0.3071.115 safari/537.36
please note using angular js client , webapi server side. performing xhr request through $resource service.
this because back-end api doesn't support options
request routes (specifically /api/home/gettext
route). angularjs typically checks cors requests issuing options
requests prior making actual content requests.
you need enable support options
requests @ back-end, , return appropriate headers + http status (200-299) there.
Comments
Post a Comment