支持CORS的服务器? [英] Servers that supports CORS?

查看:96
本文介绍了支持CORS的服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有被支持CORS许多服务器?

I wonder if there are many servers that are supporting CORS?

推荐答案

为了让您的Web服务器支持CORS,它是作为使它返回另一个头一样简单。

To make your web server support CORS, it is as easy as making it return another header.

例如,在Apache2的,只需添加这行到你的应用的conf文件:

For example, in Apache2, simply add this line to your applicable conf file:

标题设置访问控制 - 允许 - 起源*

要更加安全(或者,如果你没有访问您的服务器的conf文件),你可能想不是在你的服务器上添加此头,但只与你的服务器端code时,真的添加你想在那里。

To be more secure (or if you don't have access to your server's conf file) you might want to NOT add this header in your server, but only add it with your server-side code when you really want it there.

对于PHP例如,你可以这样做:(未经测试)

For example in PHP you could do this: (untested)

&LT ;?标题(访问控制 - 允许 - 起源*'); ?>

这篇关于支持CORS的服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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