Skip to content

Commit 3d5838d

Browse files
committed
feat(gh-proxy): API token
1 parent 0c04087 commit 3d5838d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

scripts/edgeone/edge-functions/gh/[[default]].js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ export default async function onRequest(context) {
127127
if (ifNoneMatch) headers.set("if-none-match", ifNoneMatch);
128128
if (ifModifiedSince) headers.set("if-modified-since", ifModifiedSince);
129129
headers.set("user-agent", "edgeone-gh-proxy");
130+
if (kind === "api") {
131+
const token =
132+
(context && context.env && context.env.GH_TOKEN) ||
133+
globalThis.GH_TOKEN;
134+
if (token) {
135+
headers.set("authorization", `Bearer ${token}`);
136+
}
137+
}
130138

131139
const upstream = await fetch(upstreamUrl, {
132140
method,

0 commit comments

Comments
 (0)