[에러일지] 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.

박준석·2022년 10월 28일
2

에러일지

목록 보기
1/5
post-thumbnail

🧩 에러일지..

🧩 에러발생

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.

한국말 : 'https://...'의 페이지가 HTTPS를 통해 로드되었지만 안전하지 않은 리소스 '...'를 요청했습니다. 이 요청은 차단되었습니다. 컨텐츠는 HTTPS를 통해 제공되어야 합니다.

🧩 에러원인

암호화 된 HTTPS 페이지에 암호화되지 않은 HTTP를 통해 요청할 때 발생하는 에러다.

왜냐하면... openweather API는 무료버전은 HTTPS가 아닌...HTTP이기 때문이다....

그래서 API를 사야한다. 만약 API를 구매했어도 안된다면 다음 해결 방법이 있다.

🧩 해결방법

Javascript

<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" />
profile
안녕하세요 프론트엔드 개발자입니다. 글을 이전 중입니다.

2개의 댓글

comment-user-thumbnail
2022년 10월 28일

에러일지 신선하네요! 포스팅 감사합니다🙇🏻‍♀️

1개의 답글