js实现跨域访问

1.基于nginx配置

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With,Content-Type;
add_header Access-Control-Allow-Methods PUT,GET,POST,GET,OPTIONS;

2.基于apache配置

<Directory />
    AllowOverride none
    Require all granted
    Header set Access-Control-Allow-Origin *
</Directory>

你可能感兴趣的:(js)