aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/http/headers/access-control-allow-credentials/index.html
blob: 89470b836611b76e9ed92415e87da602282d9edf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: Access-Control-Allow-Credentials
slug: Web/HTTP/Headers/Access-Control-Allow-Credentials
translation_of: Web/HTTP/Headers/Access-Control-Allow-Credentials
---
<div>{{HTTPSidebar}}</div>

<p>응답헤더 <strong><code>Access-Control-Allow-Credentials</code></strong> 는  요청의 자격증명 모드({{domxref("Request.credentials")}})가 "<code>include</code>" 일때,   브라우저들이 응답을 프로트엔드 자바스트립트 코드에 노출할지에 대해 알려줍니다.</p>

<p> 요청의 자격증명 모드가  ({{domxref("Request.credentials")}})가  "<code>include</code>" 일 때,  <code>Access-Control-Allow-Credentials</code> 값이 <code>true</code> 일 경우에만 브라우저들은 프로트엔드 자바스트립트에 응답을 노출 할 것입니다.</p>

<p>자격증명들은 쿠키, authorization 헤더들 또는 TLS 클라이언트 인증서입니다.</p>

<p>사전 요청의 응답으로 사용할 때, 실제 요청에서 자격증명을 이용할 수 있는지에 대해서 알려줍니다. 심플한 {{HTTPMethod("GET")}} 요청은 사전 요청하지 않으므로, 자격증명과 함께 리소스에 대한 요청이 만들어 지고,  응답에서 리소스와 함께 이 헤더가 없다면 브라우저는 응답을 무시하고 웹 콘텐츠가 전달 되지 않습니다.</p>

<p><code>Access-Control-Allow-Credentials</code> 헤더는 {{domxref("XMLHttpRequest.withCredentials")}} 속성이나 Fetch API 생성자의{{domxref("Request.Request()", "Request()")}}의 <code>credentials</code> 옵션과 함께 작동합니다. 자격 증명이 있는 CORS 요청의 경우, 브라우저가 프런트엔드 JavaScript 코드에 대한 응답을 노출하기 위해서는 서버(Access-Control-Allow-Credentials 헤더 사용)와 클라이언트(XHR, Fetch 또는 Ajax 요청에 대한 자격 증명 모드를 설정하여)가 자격 증명 포함을 선택하고 있음을 표시해야 합니다.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Response header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
 </tbody>
</table>

<h2 id="구문">구문</h2>

<pre class="syntaxbox notranslate">Access-Control-Allow-Credentials: true
</pre>

<h2 id="디렉티브">디렉티브</h2>

<dl>
 <dt>true</dt>
 <dd>이 해더에 유일하게 유효한 값은 <code>true</code>(대소문자 구분)입니다. 자격증명이 필요하지 않으면 값을 <code>false</code>로 설정하지 말고 이 해더 전체를 생략하세요.</dd>
</dl>

<h2 id="예제">예제</h2>

<p>Allow credentials:</p>

<pre class="notranslate">Access-Control-Allow-Credentials: true</pre>

<p>Using <a href="/en-US/docs/Web/API/XMLHttpRequest">XHR</a> with credentials:</p>

<pre class="brush: js notranslate">var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://example.com/', true);
xhr.withCredentials = true;
xhr.send(null);</pre>

<p>Using <a href="/en-US/docs/Web/API/Fetch_API">Fetch</a> with credentials:</p>

<pre class="brush: js notranslate">fetch(url, {
  credentials: 'include'
})</pre>

<h2 id="사양">사양</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Fetch','#http-access-control-allow-credentials', 'Access-Control-Allow-Credentials')}}</td>
   <td>{{Spec2("Fetch")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>

<p>{{Compat("http.headers.Access-Control-Allow-Credentials")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("XMLHttpRequest.withCredentials")}}</li>
 <li>{{domxref("Request.Request()", "Request()")}}</li>
</ul>