How can i add an "Access-Control-Allow-Origin" header?
Thank you
Urs
Tried one more hour today, unfortunately still can't get it to work...
=======
exports.install = function(framework) {
framework.route('/auth/login', auth_login, ['post', 'xhr']);
};
function auth_login() {
var self = this;
if (!self.cors('*', ['POST'])) {
self.json({foo: 'Not allowed'});
return;
}
self.json({ foo: 'Bar' });
}
=======
If i do a:
curl -X OPTIONS -ik 'http://localhost:8000/auth/login' -H "Origin: http://localhost:9000"
I get:
HTTP/1.1 404 Not Found
What's wrong with it?
Thanks
Urs
framework.route('/auth/login', auth_login, ['post']);
So, Chrome sends a preflight CORS request because I'm doing a cross domain request, which total.js can't handle?
When will it be supported?
That would be amazing!
You can get the whole package here:
https://drive.google.com/file/d/0ByPglfVV0LufT1AycWtPaFNfM2c/edit?usp=sharing
It's 27MB because it includes the whole angular setup done by yeoman.
server runs on port 8000.
You can start the client with "grunt serve", or may use the content of the "dist" folder on an other webserver ("grunt serve" runs on port 9000).
Thank you very much
Urs
I have to thank YOU!
Looks good so far. Very nice. Should have a bit more time tomorrow.
Thanks
Urs
<!DOCTYPE html><html><body>
<div id="demo"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadDoc()">Change Content</button>
<script>function loadDoc() { var xhttp = new XMLHttpRequest() , method = 'POST' , url = 'http://localhost:8000/'; xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { document.getElementById("demo").innerHTML = xhttp.responseText; } } xhttp.open( method , url , true ); xhttp.send([{"itemcode":"03300-SF-5098-0"},{"itemcode":"03300-SF-5098-0"}]);}</script>
</body></html>
exports.install = function() { F.route('/', json_users, ['post']);};
function json_users() { var self = this; var sql = DB(); console.log(self.cors('Access-Control-Allow-Origin','*')); if (!self.cors('Access-Control-Allow-Origin','*')) { self.json({ flash: 'Not allowed' }); return; } console.log('post'+self.post);}
XMLHttpRequest cannot load http://localhost:8000/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403.