今天折腾halo的时候,发现artalk出现跨域访问报错,内容如下。

1
2
Access to fetch at 'https://artk.musnow.top/api/stat' from origin 'https://halo.musnow.top' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values ', https://halo.musnow.top', but only one is allowed. 
Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

尝试在nginx里面加了一个跨域访问头,依旧没有解决这个问题

1
add_header Access-Control-Allow-Origin 'https://halo.musnow.top' always;

后来咨询其他老哥才知道,这是artalk内部可信域名配置的问题,不需要修改nginx配置文件。(记得把上方的nginx配置删掉)

我只添加了站点的可信域名,artalk系统设置里面还有一个可信域名配置

image.png

设置了之后需要重启artalk容器,才能让修改生效

1
docker restart artalk-go

现在就OK了

image.png