fix: polyfill crypto.randomUUID for insecure HTTP contexts
Build and Push to GHCR / build-and-push (push) Has been cancelled

crypto.randomUUID() is only available in secure contexts (HTTPS).
GitHub's React code uses it, so we polyfill it in the injected script
for proxies served over HTTP.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <[email protected]>
This commit is contained in:
Agent
2026-05-24 23:12:38 +08:00
co-authored by HAPI
parent 1b8e24ddb1
commit 2be1a3b220
+1
View File
@@ -169,6 +169,7 @@ func injectTokenPrefixScript(body []byte, prefix string) []byte {
script := []byte(`<script>` + script := []byte(`<script>` +
`(function(){` + `(function(){` +
`var p='` + prefix + `';` + `var p='` + prefix + `';` +
`if(typeof crypto!=='undefined'&&!crypto.randomUUID){crypto.randomUUID=function(){return'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(c){var r=Math.random()*16|0,v=c==='x'?r:(r&0x3|0x8);return v.toString(16);});};}` +
`function rw(v){return v&&v.startsWith('/')&&!v.startsWith(p+'/')&&v!==p?p+v:v};` + `function rw(v){return v&&v.startsWith('/')&&!v.startsWith(p+'/')&&v!==p?p+v:v};` +
`function rfw(u){` + `function rfw(u){` +
`if(typeof u!=='string'){` + `if(typeof u!=='string'){` +