Cross-origin request for local file

后端 未结 4 1883
无人及你
无人及你 2021-01-11 12:35

I need to open a local html file in the browser. The javascript works fine but ajax stops working and XMLHttpRequest gives a cross origin error. Is there a way to run ajax f

4条回答
  •  被撕碎了的回忆
    2021-01-11 13:03

    The simplest way to allow this in Firefox is to navigate to about:config, look for the privacy.file_unique_originsetting and toggle it off.

    Essentially, Firefox used to treat local files from the same directory as being from the same source, thus CORS was happily satisfied. That behavior changed after CVE-2019-11730 was discovered.

    It worked fine for me on 84.0.1 on Arch. Just be sure to turn it off when not locally debugging.

    Source

提交回复
热议问题