Angular CORS request blocked

前端 未结 5 432
独厮守ぢ
独厮守ぢ 2020-12-14 23:22

I am trying to connect my Angular app with a simple REST server on express. The server only sends json data in reply to request. To add CORS suppor

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 00:21

    In development environment(localhost),you can do it easily without following any of these hard steps.You can simply download https://addons.mozilla.org/firefox/addon/cors-everywhere/ if you are using firefox and i think there must be an extension for chrome also.After downloading it will come to the firefox menubar and then you can click it to activate it,thats all you can now access to all apis as it automatically sends header with all requests.For production environment you have to configure it from your server by adding access-control-allow-origin to * (all)

提交回复
热议问题