oasis-chat 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sw.js +29 -9
- package/package.json +1 -1
package/dist/sw.js
CHANGED
|
@@ -18,13 +18,23 @@ self.addEventListener('fetch', (event) => {
|
|
|
18
18
|
// /oasis/... -> /api/...로 변환하여 실제 API 서버에 요청
|
|
19
19
|
const apiPath = url.pathname.replace('/oasis', '/api');
|
|
20
20
|
|
|
21
|
-
//
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
// 허용된 헤더만 추출 (CORS 관련 문제 방지)
|
|
22
|
+
const headers = new Headers();
|
|
23
|
+
const allowedHeaders = [
|
|
24
|
+
'accept',
|
|
25
|
+
'content-type',
|
|
26
|
+
'authorization',
|
|
27
|
+
'cookie', // 쿠키 헤더 추가
|
|
28
|
+
'current-workspace-id',
|
|
29
|
+
'current-workspace-uuid',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
event.request.headers.forEach((value, key) => {
|
|
33
|
+
const lowerKey = key.toLowerCase();
|
|
34
|
+
if (allowedHeaders.includes(lowerKey)) {
|
|
35
|
+
headers.set(key, value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
28
38
|
|
|
29
39
|
// body가 있는 요청인 경우 (GET, HEAD가 아닌 경우)
|
|
30
40
|
const hasBody =
|
|
@@ -40,13 +50,23 @@ self.addEventListener('fetch', (event) => {
|
|
|
40
50
|
.arrayBuffer()
|
|
41
51
|
.then((body) => {
|
|
42
52
|
return fetch(`${TARGET_API}${apiPath}${url.search}`, {
|
|
43
|
-
|
|
53
|
+
method: event.request.method,
|
|
54
|
+
headers: headers,
|
|
55
|
+
credentials: 'include',
|
|
56
|
+
mode: 'cors',
|
|
44
57
|
body: body.byteLength > 0 ? body : undefined,
|
|
45
58
|
});
|
|
46
59
|
})
|
|
47
60
|
);
|
|
48
61
|
} else {
|
|
49
|
-
event.respondWith(
|
|
62
|
+
event.respondWith(
|
|
63
|
+
fetch(`${TARGET_API}${apiPath}${url.search}`, {
|
|
64
|
+
method: event.request.method,
|
|
65
|
+
headers: headers,
|
|
66
|
+
credentials: 'include',
|
|
67
|
+
mode: 'cors',
|
|
68
|
+
})
|
|
69
|
+
);
|
|
50
70
|
}
|
|
51
71
|
}
|
|
52
72
|
});
|