nginx 위 챗 이미지 canvas 크로스 도 메 인 문제 해결

1. 배경 소개
위 챗 h5 인터페이스 는 캡 처 를 생 성하 고 전단 canvas 방안 을 채택 하여 크로스 필드 가 나타 나 야 합 니 다.
2. 해결 방안
인터페이스 가 aa.bb.cc/mydemo/index.html nginx 에서 설정 된다 고 가정 합 니 다.
	location /mydemo/wechat/image/{
		add_header 'Access-Control-Allow-Origin' "$http_origin" always;
		add_header 'Access-Control-Allow-Credentials' 'true' always; 
		add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always; 
		add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-  Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
		proxy_pass http://thirdwx.qlogo.cn/;
	}

이렇게
aa.bb.cc/mydemo/wechat/image/+xxx

의 링크 에서 위 챗 이미지 에 접근 할 수 있 습 니 다. 더 이상 canvas 크로스 오 류 를 일 으 키 지 않 습 니 다.

좋은 웹페이지 즐겨찾기