fix: polyfill crypto.randomUUID for insecure HTTP contexts
Build and Push to GHCR / build-and-push (push) Has been cancelled
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:
@@ -169,6 +169,7 @@ func injectTokenPrefixScript(body []byte, prefix string) []byte {
|
||||
script := []byte(`<script>` +
|
||||
`(function(){` +
|
||||
`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 rfw(u){` +
|
||||
`if(typeof u!=='string'){` +
|
||||
|
||||
Reference in New Issue
Block a user