javascript - XHR cross-domain error on the same domain (localhost) -
explanation:
i have small web application running on apache server on machine uses javascript xhr's. long time worked no problems, today xhr's stopped working on localhost, if access outside works perfectly.
problem:
using mozilla firefox, firebug warns:
"cross-origin request blocked: same origin policy disallows reading remote resource @
http://127.0.0.1:3581/datasnap/rest/tdssmloteamento/getloteamento/true/
. can fixed moving resource same domain or enabling cors."
but i'm on localhost acessing local content have xhr calls local datasnap server on same machine, resuming, locally fails, , web works.
comments:
i acessing apache web page within url: http://127.0.0.1:3582/beewebloteamento/principal.php
this totally, really, weird me, not make sense, no-logic, why cross-domain error if i'm acessing same domain?
objective:
i want know happening , solve problem continue doing xhr's locally , via web (external) too.
i found solution/problem, is:
replaced 127.0.0.1
192.168.25.100
(that local machine ip) , worked fine, request was:
http://127.0.0.1:3581/datasnap/rest/tdssmloteamento/getloteamento/true/
and became:
http://192.168.25.100:3581/datasnap/rest/tdssmloteamento/getloteamento/true/
and acessed web application (apache) within url:
http://192.168.25.100:3582/beewebloteamento/principal.php
resuming:
to avoid these cross-domain problems, use local ip address of machine "that starts 192.168.xxx.xxx
" access hosted on it, nor xhr either apache, instead of using 127.0.0.1
or localhost
Comments
Post a Comment