Heim >Backend-Entwicklung >PHP-Tutorial >nginx中配置跨域支持功能

nginx中配置跨域支持功能

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:55:281139Durchsuche

在nginx.conf中配置
http {
  ......
  add_header Access-Control-Allow-Origin *;
  add_header Access-Control-Allow-Headers X-Requested-With;
  add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
  ......
}
这样就可以实现GET,POST,OPTIONS的跨域请求的支持

也可以 add_header Access-Control-Allow-Origin http://test.51testing.com; --指定允许的url;

转载地址:http://www.51testing.com/html/96/215196-829360.html

以上就介绍了nginx中配置跨域支持功能,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn