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

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

    Accepted answer is fine, in case you prefer something shorter, you may use a plugin called cors available for Express.js

    It's simple to use, for this particular case:

    var cors = require('cors');
    
    // use it before all route definitions
    app.use(cors({origin: 'http://localhost:8888'}));
    
    0 讨论(0)
提交回复
热议问题