ajax请求跨域问题The ‘Access-Control-Allow-Origin’ header contains multiple values ‘*, *’

使用ajax请求zabbix监控系统的api接口,遇到以下错误:

Access to XMLHttpRequest at ‘http://192.168.55.18/visqual/api_jsonrpc.php’ from origin ‘http://192.168.2.103:8006’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘*, *’, but only one is allowed.

出现这个报错是因为nignx配置了准许所有网站地址通行,而api程序中也设置了。重复的Access-Control-Allow-Origin:*配置引起的错误。

把nignx的配置或者代码的配置注释掉就能正常发起请求了。