环境运维

umami iframe 跨域调用时,status出现(blocked:other)

解决方法

删除next.config.js下的以下代码:

 {
    key: 'Content-Security-Policy',
    value: contentSecurityPolicy
      .join(';')
      .replace(/\s{2,}/g, ' ')
      .trim(),
  },

重新yarn build  

yarn start 

即可

 

nginx相关配置


    # 允许单个域名iframe嵌套
    add_header X-Frame-Options "ALLOWALL";
       
# 允许跨域的请求,可以自定义变量$http_origin,*表示所有

add_header 'Access-Control-Allow-Origin' '*';

# 允许携带cookie请求

add_header 'Access-Control-Allow-Credentials' 'true';

# 允许跨域请求的方法:GET,POST,OPTIONS,PUT

add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT';

# 允许请求时携带的头部信息,*表示所有

add_header 'Access-Control-Allow-Headers' '*';

# 允许发送按段获取资源的请求

add_header 'Access-Control-Expose-Headers' 'Content-Length, Content-Range';