node.js - heroku node js simple cross-domain issue -
i worked 2 nodejs (no express) application :
webprocess dataprocess
dataprocess sends rest message code :
var status = 200; if (responsestatus) { status = responsestatus; } var contenttype = "application/json; charset=utf-8"; if (responsecontenttype) { contenttype = responsecontenttype; } this.response.statuscode = status; //http://www.w3.org/tr/cors/ //the server allows domain call xmlhttprequest this.response.setheader("access-control-allow-origin", this.request.headers.origin); //the server allow content-type header this.response.setheader("access-control-allow-headers", "content-type"); this.response.setheader("access-control-allow-methods", "get,post,put,delete,options"); this.response.setheader("content-type", contenttype); this.response.end(contenttext);
in local, ok, "access-control-allow-origin" works fine. but, when create 2 apps on heroku , deploy, browser cross-domain exception on pre-flight ajax call (options). not sure what's wrong?
thanks help
yoann
if want allow domain call endpoint per comment in code, use wildcard instead of this.request.headers.origin
//the server allows domain call xmlhttprequest this.response.setheader("access-control-allow-origin", "*");
Comments
Post a Comment