referrerPolicy()
함수 시그니처
referrerPolicy: (policy: HTTPReferrerPolicy) => R
관련 RequestInit 속성
{
referrerPolicy: policy
}
설명
Fetch API의 RequestInit.referrerPolicy 값을 설정합니다. 요청을 보낼 때 Referer 헤더에 포함할 출처 정보를 제어합니다.
사용 가능한 값은 다음과 같습니다.
| enum | 실제 값 |
|---|---|
HTTPReferrerPolicy.NO_REFERRER | 'no-referrer' |
HTTPReferrerPolicy.NO_REFERRER_WHEN_DOWNGRADE | 'no-referrer-when-downgrade' |
HTTPReferrerPolicy.ORIGIN | 'origin' |
HTTPReferrerPolicy.ORIGIN_WHEN_CROSS_ORIGIN | 'origin-when-cross-origin' |
HTTPReferrerPolicy.SAME_ORIGIN | 'same-origin' |
HTTPReferrerPolicy.STRICT_ORIGIN | 'strict-origin' |
HTTPReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN | 'strict-origin-when-cross-origin' |
HTTPReferrerPolicy.UNSAFE_URL | 'unsafe-url' |
예제
import { dench, HTTPReferrerPolicy } from 'dench-fetch';
const api = dench('https://api.example.com');
const response = await api
.get('/resource')
.referrerPolicy(HTTPReferrerPolicy.NO_REFERRER)
.toResponse();
실제 RequestInit은 다음과 같습니다.
{
method: 'GET',
referrerPolicy: 'no-referrer',
}
주의사항
- 실제
Referer헤더는 브라우저와 실행 환경의 보안 정책에 따라 추가로 제한될 수 있습니다. HTTPReferrerPolicy.UNSAFE_URL은 요청 URL의 경로와 쿼리 정보가 전달될 수 있으므로 민감한 정보 노출에 주의해야 합니다.