오르막길
[React] 리액트 jsx에서 외부 소스 이미지 엑박 오류 해결법 본문
공공데이터 포털에서 제공하는 이미지 링크를 사용하려는데, 이미지가 뜨지 않고 엑스박스(엑박)이 떠서 당황했던 적이 있었다.
구글링해본 결과, img 형식을 지켜야하는 것은 같지만, 추가로 지정해줘야하는 부분이 있었다.
바로 refferPolicy를 설정해준다는 것이다.
<img
className="handImage"
src={link}
referrerPolicy="no-referrer"
/>
Referrer-Policy - HTTP | MDN
The Referrer-Policy HTTP header controls how much referrer information (sent with the Referer header) should be included with requests. Aside from the HTTP header, you can set this policy in HTML.
developer.mozilla.org
상세 설정 방법은 다음과 같다.
no-referrer
The [Referer](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer>) header will be omitted: sent requests do not include any referrer information.
no-referrer-when-downgrade
Send the origin, path, and querystring in [Referer](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer>) when the protocol security level stays the same or improves (HTTP→HTTP, HTTP→HTTPS, HTTPS→HTTPS). Don't send the [Referer](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer>) header for requests to less secure destinations (HTTPS→HTTP, HTTPS→file).
origin
Send only the origin in the [Referer](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer>) header. For example, a document at https://example.com/page.html will send the referrer https://example.com/.
origin-when-cross-origin
When performing a same-origin request to the same protocol level (HTTP→HTTP, HTTPS→HTTPS), send the origin, path, and query string. Send only the origin for cross origin requests and requests to less secure destinations (HTTPS→HTTP).
same-origin
Send the origin, path, and query string for same-origin requests. Don't send the [Referer](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer>) header for cross-origin requests.
strict-origin
Send only the origin when the protocol security level stays the same (HTTPS→HTTPS). Don't send the [Referer](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer>) header to less secure destinations (HTTPS→HTTP).
strict-origin-when-cross-origin (default)
Send the origin, path, and querystring when performing a same-origin request. For cross-origin requests send the origin (only) when the protocol security level stays same (HTTPS→HTTPS). Don't send the [Referer](<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer>) header to less secure destinations (HTTPS→HTTP).
'문제 해결하기 > FE' 카테고리의 다른 글
[React] 자식이 부모에게 prop을 주는 방법? (0) | 2023.02.20 |
---|---|
[React] React에서 외부 스크립트 연결하기, 전역변수 (0) | 2023.02.06 |
[CSS] SCSS, MUI, styled-component, emotion (0) | 2023.02.06 |
[React+OpenVidu]완전 초보자가 OpenVidu를 React로 만져본 기록 (0) | 2023.01.28 |