0

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...

Haji
  • 1,715
  • 7
  • 25
  • 41
  • Is [this](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en) perhaps what you're looking for? –  Apr 28 '14 at 16:39
  • No, since I can't run any extensions (running Chrome with `--disable-extensions`) – Haji Apr 30 '14 at 06:23

3 Answers3

1

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).

aka_007
  • 269
  • 1
  • 4
  • 13
0

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?

Community
  • 1
  • 1
Weimin Ye
  • 665
  • 4
  • 15
  • Thanks Billy Yeah, but I don't think it can solve my problem: the resource in localhost:9222/json can't be opened as a local file (the http protocol can't be replaced with file:// in any way, I believe). I'm trying to access this resource from a page that can run either on a localhost server or as a local file, but I don't think it matters because the resource I'm trying to access (localhost:9222/json) is not a file. Am I wrong? – Haji Apr 28 '14 at 13:54
  • Yes, I did. Doesn't help. – Haji Apr 29 '14 at 06:04
0

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.

Haji
  • 1,715
  • 7
  • 25
  • 41