altv-issues icon indicating copy to clipboard operation
altv-issues copied to clipboard

WebView | setExtraHeader not working

Open Revyn112 opened this issue 3 years ago • 2 comments

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

Revyn112 avatar Jan 03 '22 22:01 Revyn112

Im not sure if the extra headers are only used for the resources that are loaded inside the site and not the site itself.

FabianTerhorst avatar Jan 03 '22 22:01 FabianTerhorst

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.

Revyn112 avatar Jan 04 '22 14:01 Revyn112

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.

riffy avatar Mar 02 '23 09:03 riffy

https://bitbucket.org/chromiumembedded/cef/issues/1225/no-way-to-pass-extra-headers-to

FabianTerhorst avatar Mar 02 '23 09:03 FabianTerhorst

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().

riffy avatar Mar 02 '23 10:03 riffy

Fixed in dev/15.0-dev918

zziger avatar Dec 01 '23 15:12 zziger