XMLHttpRequest ... Origin http://localhost is not allowed by Access-Control-Allow-Origin.
1 réponse
Une Bévue
j(ai un script js qui fait un xhr sur un serveur local (python/mango)
"http://localhost:27080/_hello"
si je pointe mon butineur directement sur cette URL, j'obtiens :
{"ok" : 1, "msg" : "Uh, we had a slight weapons malfunction, but uh...
everything's perfectly all right now. We're fine. We're all fine here
now, thank you. How are you?"}
maintenant si je le fais par js, en xhr, j'ai l'erreur suivante :
XMLHttpRequest cannot load http://localhost:27080/_hello. Origin
http://localhost is not allowed by Access-Control-Allow-Origin.
j'ai googelisé, sans trouvé de solution (en js), je sais qu'il faut
avoir un header avec :
Access-Control-Allow-Origin: *
ben je ne pige pas vraiment et surtout comment et où mettre ce header ?
mon serveur "sleepy.mongoose-master" est lancé par :
.-[yt@d620.local:~/Sites/sleepy.mongoose-master]-[14:13:04]
'->$ python httpd.py
il me répond :
=================================
| MongoDB REST Server |
=================================
listening for connections on http://localhost:27080