Allow Google Chrome to use XMLHttpRequest to load a URL from a local file

后端 未结 4 2079
猫巷女王i
猫巷女王i 2020-11-22 07:41

When trying to do a HTTP request using XMLHttpRequest from a local file, it basically fails due to Access-Control-Allow-Origin violation.

However, I\'m

4条回答
  •  花落未央
    2020-11-22 08:06

    startup chrome with --disable-web-security

    On Windows:

    chrome.exe --disable-web-security
    

    On Mac:

    open /Applications/Google\ Chrome.app/ --args --disable-web-security
    

    This will allow for cross-domain requests.
    I'm not aware of if this also works for local files, but let us know !

    And mention, this does exactly what you expect, it disables the web security, so be careful with it.

提交回复
热议问题