Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决图片跨域 #18

Open
sunniejs opened this issue Jun 22, 2020 · 9 comments
Open

解决图片跨域 #18

sunniejs opened this issue Jun 22, 2020 · 9 comments

Comments

@sunniejs
Copy link
Owner

关于项目大家问的最多的问题就是图片出现了跨域,大家可以在这里积极的提出解决方案。

@sunniejs sunniejs pinned this issue Jun 22, 2020
@sunniejs
Copy link
Owner Author

sunniejs commented Jun 22, 2020

1.如果图片在你自己的服务器上,配置nginx

location / {  
	 add_header Access-Control-Allow-Origin *;
  	 add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
  	 add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
                add_header Access-Control-Allow-Credentials "true";
         if ($request_method = "OPTIONS") { 
                    add_header Access-Control-Allow-Origin *; 
                   add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
                   return 204; 
  	}
    
  }  
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  {
      add_header Access-Control-Allow-Origin *;
      expires      30d;
      error_log off;
      access_log /dev/null;
  }

@superggh
Copy link

我的是阿里oss 特别麻烦

@leozhang136
Copy link

阿里云oss 怎么处理呢

@newbaner
Copy link

+1

@sunniejs
Copy link
Owner Author

我的是阿里oss 特别麻烦

我阿里云上的图片可以直接用啊,阿里云oss有跨域设置吧

@penghao-06
Copy link

大佬,阿里oss 跨域怎么解决的

@penghao-06
Copy link

+1

阿里云oss怎么处理呢
大佬,请问阿里的oss怎么解决的

@pqx1993
Copy link

pqx1993 commented Jun 24, 2021

请问OSS跨域问题怎么解决的,为什么我的配置允许跨域,还是报错?

@husky-wdy
Copy link

有大佬解决了跨域的问题了吗?好蛋疼,阿里云的oss也配了,还是报跨域

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants