How to enable CORS

61 views
Skip to first unread message

Rodrigo Reis

unread,
Feb 5, 2014, 1:18:07 AM2/5/14
to locomo...@googlegroups.com
I found this way using express: http://enable-cors.org/server_expressjs.html

How can I do that with Locomotive?

Truong LD

unread,
Mar 21, 2014, 7:49:06 AM3/21/14
to locomo...@googlegroups.com
add some lines to top of your controller function to enable CORS for that function. 
For example:
 
ItemController.update = function() {
    // enable CORS
    this.res.header("Access-Control-Allow-Origin", "*"); 
    this.res.header("Access-Control-Allow-Headers", "X-Requested-With"); 
    this.res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
    this.res.header('Access-Control-Allow-Headers', 'Content-Type');
    //your main processing code here ...
}

Vào 13:18:07 UTC+7 Thứ tư, ngày 05 tháng hai năm 2014, Rodrigo Reis đã viết:
Reply all
Reply to author
Forward
0 new messages