Skip to content

Commit ced4987

Browse files
committed
可以设定请求头中的字段"x-proxy-redirect"为"error" | "follow" | "manual"来设定代理行为的重定向方式.
1 parent 8b5f371 commit ced4987

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ http://localhost:8000/token/token123456/https/www.360.cn
3434
```
3535
http://localhost:8000/token/token123456/http/example.com
3636
```
37+
38+
可以设定请求头中的字段"x-proxy-redirect"为"error" | "follow" |
39+
"manual"来设定代理行为的重定向方式.

middleware.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ export async function reverse_proxy(
182182
method: request.method,
183183
body: request.body,
184184
/* 关闭重定向 */
185-
redirect: "manual",
185+
/* 可以设定请求头中的字段"x-proxy-redirect"为"error" | "follow" |
186+
"manual"来设定代理行为的重定向方式. */
187+
redirect: (requestHeaders.get("x-proxy-redirect") ??
188+
"manual") as RequestRedirect,
186189
});
187190
console.log(
188191
JSON.stringify(

0 commit comments

Comments
 (0)