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

后端 未结 13 1696
有刺的猬
有刺的猬 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:19

    This worked for me.

    app.get('/', function (req, res) {
    
        res.header("Access-Control-Allow-Origin", "*");
        res.send('hello world')
    })
    

    You can change * to fit your needs. Hope this can help.

提交回复
热议问题