No 'Access-Control-Allow-Origin' - Node / Apache Port Issue

后端 未结 13 1664
有刺的猬
有刺的猬 2020-11-22 02:27

i\'ve created a small API using Node/Express and trying to pull data using Angularjs but as my html page is running under apache on localhost:8888 and node API is listen on

13条回答
  •  有刺的猬
    2020-11-22 03:12

    You can use "$http.jsonp"

    OR

    Below is the work around for chrome for local testing

    You need to open your chrome with following command. (Press window+R)

    Chrome.exe --allow-file-access-from-files
    

    Note : Your chrome must not be open. When you run this command chrome will open automatically.

    If you are entering this command in command prompt then select your chrome installation directory then use this command.

    Below script code for open chrome in MAC with "--allow-file-access-from-files"

    set chromePath to POSIX path of "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" 
    set switch to " --allow-file-access-from-files"
    do shell script (quoted form of chromePath) & switch & " > /dev/null 2>&1 &"
    

    second options

    You can just use open(1) to add the flags: open -a 'Google Chrome' --args --allow-file-access-from-files

提交回复
热议问题