Reputation: 1775
I debug Chrome remotely by opening it with the --remote-debugging-port
switch, as described here.
I have another page running on a different port (on my localhost as well) and issuing an HTTP request to: http://localhost:9222/json
. This fails due to a cross-domain problem ("No Access-Control-Allow-Origin"), since the request is issued from a different port.
Can I somehow change the Chrome remote debugger's localhost server headers to support cross-domain? I just need to find a way to call that http://localhost:9222/json
from a different host...
Upvotes: 0
Views: 2596
Reputation: 269
I don't think this is possible. I am need of this feature too. I have tried to launch chrome (which I want to debug) using the flags "--disable-web-security" and "--allow-file-access-from-files". When I try to access the page "localhost:9222/json" from another port say "localhost:8000" it throws error http://pastebin.com/JHYy8uLk
This can however be done using a middle-man(server) which entertains get requests. The page localhost:8000 can send "get" request to this middle-man, which will fetch json data from localhost:9222/json(No violation of same origin policy), and return this data to localhost:8000.
Since my localhost:8000 was running on a Django server, I can use the server itself to fetch data from localhost:9222/json(i.e. the django controller).
Upvotes: 1
Reputation: 1775
The way I did it was by running Chrome with the switch --disable-web-security
that overrides the enforcement of the same origin policy. This solution obviously has its drawbacks (e.g. a notification bar saying that stability and security will suffer) but for my needs it seems good enough at the moment.
Upvotes: 0
Reputation: 665
You should launch Chrome at “allow-file-access-from-files” mode to resolve this issue.
More detailed information about allow-file-access-from-files mode please see here: How to launch html using Chrome at "--allow-file-access-from-files" mode?
Upvotes: 0