altv-issues
altv-issues copied to clipboard
WebView | setExtraHeader not working
Description of the problem
When setting an extraHeader in client in the WebView i can't fetch them on php web server-side.
With the code below i get with altv the followering output:
Accept-Encoding: gzip, deflate, br
Sec-Fetch-Dest: document
Sec-Fetch-User: ?1
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Accept-Language: de_DE
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Connection: close
X-Accel-Internal: /internal-nginx-static-location
Reproduction steps
Client Side
mainView.setExtraHeader('tokenfirst', '1');
mainView.setExtraHeader('tokensecond', '2');
mainView.url = 'https://domain.net/test.php';
mainView.setExtraHeader('tokenthird', '3');
mainView.setExtraHeader('tokenfourth', '4');
PHP Server Side
<?php
$headers = getallheaders();
foreach($headers as $key=>$val){
echo $key . ': ' . $val . '<br>';
}
Expected behaviour
I've expect to see in the result any of this header i've set.
Additional context
When using POSTMAN and set the headers by myself there, i've got them on server side. So the php script is working.
Operating system
Ubuntu20.04/Windows11
Version
release/8.8
Im not sure if the extra headers are only used for the resources that are loaded inside the site and not the site itself.
Im not sure if the extra headers are only used for the resources that are loaded inside the site and not the site itself.
So will it be possible to set ExtraHeaders for the site itself? Would be very nice for set tokens for authentication and some stuff.
Assuming this still isn't fixed: Any news on this? Or can we move the priority up? Using JWT or other headers in the request would be nice.
https://bitbucket.org/chromiumembedded/cef/issues/1225/no-way-to-pass-extra-headers-to
Thanks for the info.
I think this is worth mentioning in the docs of https://docs.altv.mp/js/api/alt-client.WebView.html#_altmp_altv_types_alt_client_WebView_setExtraHeader with the workaround Create the browser with "about:blank" and then navigate using LoadRequest().
Fixed in dev/15.0-dev918