Skip to content

Commit 665d4e9

Browse files
cyfung1031CodFrm
andauthored
🐛 删除 fetchScriptBody 的 Accept,避免触发 Error 406 (#1306)
* 修正 fetchScriptBody 的 Accept 设定,避免触发 Error 406 * 🐛 移除 Accept 头和 content-type 验证,避免触发 Error 406 --------- Co-authored-by: 王一之 <yz@ggnb.top>
1 parent 7d9510d commit 665d4e9

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ CLAUDE.md
3939

4040
test-results
4141
playwright-report
42+
43+
superpowers

src/pages/install/App.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ const fetchScriptBody = async (url: string, { onProgress }: { [key: string]: any
6767
const response = await fetch(url, {
6868
headers: {
6969
"Cache-Control": "no-cache",
70-
Accept: "text/javascript,application/javascript,text/plain,application/octet-stream,application/force-download",
7170
// 参考:加权 Accept-Encoding 值说明
7271
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Accept-Encoding#weighted_accept-encoding_values
7372
"Accept-Encoding": "br;q=1.0, gzip;q=0.8, *;q=0.1",
@@ -83,10 +82,6 @@ const fetchScriptBody = async (url: string, { onProgress }: { [key: string]: any
8382
if (!response.body || !response.headers) {
8483
throw new Error("No response body or headers");
8584
}
86-
if (response.headers.get("content-type")?.includes("text/html")) {
87-
throw new Error("Response is text/html, not a valid UserScript");
88-
}
89-
9085
const reader = response.body.getReader();
9186

9287
// 读取数据

0 commit comments

Comments
 (0)