“ Access-Control-Allow-Origin”标头包含多个值“ http://localhost:4200,“ AWS上我的服务器的IP”,但只允许一个。因此,不允许访问来源“ http://localhost:4200”。
我的nginx文件如下:
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST,PUT,OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';