javascript - Can't send PUT Request because of Access-Control-Allow-Methods in preflight response -
i know, common topic , have checked many of questions on stackoverflow. case kind of different, because don't problem. basically, know how handle cors, , tried many solutions.
let me explain situation:
my setup ionic project (on localhost), sends via http request put self hosted directus headless-cms. , post work perfectly. when try request via postman, works well. know postman sends automatically additional headers within request. tried add them in code well, still same respone message.
this response code snippet within ionic
var jsonbody = {}; jsonbody['german'] = "lorem ipsum"; jsonbody['turoyo'] = "lorem ipsum"; jsonbody['description'] = "lorem ipsum"; console.log(jsonbody); this.http.put('http://example.com/api/1.1/tables/translation/rows/1?access_token=myaccesstoken', jsonbody, {headers: headers}) .subscribe( (response) => { //foo }, (error) => { //bar }, () => { //foobar } ); in browser console message after trying request:
xmlhttprequest cannot load http://example.com/api/1.1/tables/translation/rows/1?access_token=myaccesstoken. method put not allowed access-control-allow-methods in preflight response.
in postman, works breeze. look
you have possibility in postman generate according code snippet request. in case it's:
anybody idea did wrong? maybe missed detail. tried add headers nginx sites-enabled configuration. didn't make difference. makes no sense me, because postman did send request.
thanks!
finally tried solution , works:
https://michielkalkman.com/snippets/nginx-cors-open-configuration/
i put cors statements locations rule.
anyways strange me, worked tool mentioned.


Comments
Post a Comment