诗人橙V 发表于 2024-5-25 23:10:40

【已完成】资源下载跨域有没有知道怎么解决一下

Access to XMLHttpRequest at 'https://api.xxxx.com/down_zip/20240525230916142963336.zip' from origin 'https://www.bbbb.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

下载png,jpg后缀的就没问题

zip后缀的就会跨域

诗人橙V 发表于 2024-5-25 23:11:28


#PROXY-START/

location ^~ /
{
    proxy_pass http://127.0.0.1:1300;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    #允许跨域请求的域,* 代表所有
    add_header 'Access-Control-Allow-Origin' *;
    #允许请求的header
    add_header 'Access-Control-Allow-Headers' *;
    #允许带上cookie请求
    add_header 'Access-Control-Allow-Credentials' 'true';
    #允许请求的方法,比如 GET,POST,PUT,DELETE
    add_header 'Access-Control-Allow-Methods' *;
    add_header X-Cache $upstream_cache_status;
    #Set Nginx Cache

    set $static_filevO5uJYW3 0;
    if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
    {
      set $static_filevO5uJYW3 1;
      expires 1m;
    }
    if ( $static_filevO5uJYW3 = 0 )
    {
      add_header Cache-Control no-cache;
    }
}
#PROXY-END/

运维技术阿闯 发表于 2024-5-27 09:34:13

诗人橙V 发表于 2024-5-25 23:11
#PROXY-START/

location ^~ /


您好,暂时不考虑从Nginx上解决跨域的问题,而且大厂的浏览器也会逐步禁止浏览器跨域

诗人橙V 发表于 2024-5-27 10:27:25

运维技术阿闯 发表于 2024-5-27 09:34
您好,暂时不考虑从Nginx上解决跨域的问题,而且大厂的浏览器也会逐步禁止浏览器跨域 ...

那这个我要怎么处理下,解决这个问题

运维技术阿闯 发表于 2024-5-27 12:22:57

诗人橙V 发表于 2024-5-27 10:27
那这个我要怎么处理下,解决这个问题

您好,这个是解决不了的呢
页: [1]
查看完整版本: 【已完成】资源下载跨域有没有知道怎么解决一下