Access-Control-Allow-Origin Error..(using cordova)

后端 未结 4 1046
刺人心
刺人心 2021-01-28 10:30

I\'m trying to web server and client..(Hybrid app! using cordova) But Access-Control-Allow-Origin error..so I downloaded chrome extension program cors.. but doesn\'t working..

相关标签:
4条回答
  • 2021-01-28 10:55

    Try using the cors in you app middleware

    app.use(cors());
    
    0 讨论(0)
  • 2021-01-28 10:59

    This might be related to chrome issue if your cordova is using chrome as a default browser of webview. I've encounter the issue on v76.0.3809.89 of chrome and updating to v76.0.3809.111 solved the Access-Control-Allow-Origin issue.

    0 讨论(0)
  • 2021-01-28 11:02
        app.use(function(req, res, next) {
        res.header("Access-Control-Allow-Origin", "*");
        res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
        next();
    });
    

    You can use like this also , may be it will help.

    0 讨论(0)
  • 2021-01-28 11:12

    You need to add the whitelist plugin,

    https://github.com/apache/cordova-plugin-whitelist

    In config.xml add

    <!-- will not stop any calls -->
    <access origin="*" />
    
    0 讨论(0)
提交回复
热议问题