这篇文章上次修改于 1130 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

群晖内置nginx允许跨域访问

修改nginx 代理配置
vim /usr/syno/share/nginx/Portal.mustache
在location / 下面任意位置加入 : add_header Access-Control-Allow-Origin ‘*’ always;

  location / {
        {{#customize_header_variable}}
        if (${{&.}} = false) {
            set ${{&.}} '';
        }
    {{/customize_header_variable}}

# →→ 比如在这里加入 ←←

 add_header Access-Control-Allow-Origin '*' always;
注意不能用webstation直接访问,要用控制面板——Application Portal——Reverse Proxy 代理端口访问。