728x90

 

728x90

 

🐞 에러발생

프로젝트 진행 완료 후 github에 배포를 하자마자 에러가 발생했다. openweather api를 도시별로 가져오는 과정에서 HTTP, HTTPS 관련해서 문제가 발생한 것 같다.

 

Mixed Content : The page at 'https://...' was loaded over HTTPS, but requested an insecure resource '...'. This request has been blocked; the content must be served over HTTPS.

번역을 해보면 'http://..'의 페이지가 HTTPS를 통해 로드되었지만 완전하지 않은 리소스 '...' 를 요청했다. 이 요청은 차단 되었고 컨텐츠는 HTTPS를 통해 제공되어야 한다.

 

 

🐞 에러 원인

암호화 된 HTTPS 페이지에 암호화 되지 않은 HTTP를 통해 요청할 때 발생하는 에러다. 내가 배포한 사이트 주소는 HTTPS고 내가 쓴 API는 무료버전이라 HTTPS가 아닌 HTTP이기 때문에 에러가 발생한 것이다.

 

🐞 해결

  • <head></head> 사이에 아래 코드를 추가한다.
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

 

  • React 일 경우

public -> index.html 파일 <head></head> 사이에 아래 코드를 추가한다.

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
728x90