【转】angular使用代理解决跨域

原文: https://www.cnblogs.com/sghy/p/9111293.html

-----------------------------------------------------

angular2、angular4、angular5 及以上版本的跨域问题。

通过angular自身的代理转发功能

配置package.json 

两种方式启动代理服务 
第一种: 
启动项目通过npm start启动,会自动启动代理服务

npm start

第二种: 
或者直接以下命令启动代理服务

ng serve  --proxy-config proxy.conf.json

 官网介绍:https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/proxy.md

猜你喜欢

转载自www.cnblogs.com/oxspirt/p/11691750.html