From 31b5031f8631f8cc58140e6fc0f897804c8909f6 Mon Sep 17 00:00:00 2001 From: Agent Date: Sun, 24 May 2026 22:22:07 +0800 Subject: [PATCH] fix: intercept fetch/XHR to route github requests back through proxy GitHub pages use JS-driven fetch/XMLHttpRequest calls that bypass the proxy entirely, causing CORS errors. Monkey-patch both APIs in the injected script to rewrite github.com/raw/githubusercontent/ api.github.com URLs to go through the proxy prefix. via [HAPI](https://hapi.run) Co-Authored-By: HAPI --- internal/proxy/github.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/proxy/github.go b/internal/proxy/github.go index 8919130..a9c834a 100644 --- a/internal/proxy/github.go +++ b/internal/proxy/github.go @@ -157,11 +157,15 @@ func rewriteURL(u string, prefix string) string { } // injectTokenPrefixScript 在 HTML 中注入 JS 脚本,重写所有链接使其包含 token 前缀 +// 同时拦截 fetch / XMLHttpRequest,将直接访问 github.com 的请求也转回代理。 func injectTokenPrefixScript(body []byte, prefix string) []byte { script := []byte(`