fix: dev-console capture uses Blob with JSON content-type and fetch fallback
sendBeacon with a plain string sends Content-Type text/plain, which can be silently blocked in Telegram WebView. Use a Blob with application/json instead, and fall back to fetch with keepalive when sendBeacon is unavailable or returns false. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b5fda32416
commit
4d992a260e
1 changed files with 5 additions and 1 deletions
|
|
@ -439,7 +439,11 @@ const devProxyScript = `<script data-dev-proxy>
|
|||
_timer=null;
|
||||
if(!_buf.length)return;
|
||||
var batch=_buf.splice(0,20);
|
||||
try{navigator.sendBeacon('/miniapp/dev/console',JSON.stringify(batch));}catch(e){}
|
||||
var payload=JSON.stringify(batch);
|
||||
try{
|
||||
if(navigator.sendBeacon&&navigator.sendBeacon('/miniapp/dev/console',new Blob([payload],{type:'application/json'})))return;
|
||||
}catch(e){}
|
||||
try{fetch('/miniapp/dev/console',{method:'POST',headers:{'Content-Type':'application/json'},body:payload,keepalive:true});}catch(e){}
|
||||
}
|
||||
function _cap(level,args){
|
||||
var msg=Array.prototype.map.call(args,function(a){
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue