好好爱自己!

【转】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

posted @ 2019-10-17 14:19  立志做一个好的程序员  阅读(597)  评论(0编辑  收藏  举报

不断学习创作,与自己快乐相处