How to launch html using Chrome at “--allow-file-access-from-files” mode?

前端 未结 11 1656
我寻月下人不归
我寻月下人不归 2020-11-21 23:12

I have the same situation with HERE

And to solve this problem I have to launch html file using Chrome at \"--allow-file-access-from-files\" mode. I tried next steps

11条回答
  •  名媛妹妹
    2020-11-21 23:59

    That flag is dangerous!! Leaves your file system open for access. Documents originating from anywhere, local or web, should not, by default, have any access to local file:/// resources.

    Much better solution is to run a little http server locally.

    --- For Windows ---

    The easiest is to install http-server globally using node's package manager:

    npm install -g http-server

    Then simply run http-server in any of your project directories:

    Eg. d:\my_project> http-server

    Starting up http-server, serving ./
    Available on:
     http:169.254.116.232:8080
     http:192.168.88.1:8080
     http:192.168.0.7:8080
     http:127.0.0.1:8080
    Hit CTRL-C to stop the server
    

    Or as prusswan suggested, you can also install Python under windows, and follow the instructions below.

    --- For Linux ---

    Since Python is usually available in most linux distributions, just run python -m SimpleHTTPServer in your project directory, and you can load your page on http://localhost:8000

    In Python 3 the SimpleHTTPServer module has been merged into http.server, so the new command is python3 -m http.server.

    Easy, and no security risk of accidentally leaving your browser open vulnerable.

提交回复
热议问题