群晖的http接口默认是不支持跨域的,在DSM UI上也没有可以开启的地方。研究了一番,最终发现群晖是使用nginx实现的http接口。
既然是nginx,那就好办了,群晖的nginx配置文件在/etc/nginx/nginx.conf,找到自己想要的端口的server节点,add_header跨域所需要的头即可:
server {
……
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Allow-Credentials 'true';
add_header Access-Control-Allow-Headers 'X-Requested-With,Content-Type';……
}