如何在angular2中使用CORS [英] How to use CORS in angular2

查看:49
本文介绍了如何在angular2中使用CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在angular2中如何使用CORS跨域,有必要在服务器上设置响应头,如何设置?

In angular2 how to use CORS cross domain, it is necessary to set the response header at the server, how to set?

推荐答案

您只需要在服务器端而非客户端设置跨域起源.因此,请在服务器端启用CORS.

You need to set the cross domain origin in only server side not in client side. So enable CORS in server side.

如果您正在使用Web Api进行服务器调用.启用CORS和Access-Control-Allow-Origin.

And if you are using Web Api for a server call . Enable CORS and Access-Control-Allow-Origin.

这篇关于如何在angular2中使用CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆