Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fetch has incorrect response header on Android but works on Simulator

I'm testing a simple fetch from my server that should include custom headers in the response, this works perfectly fine on the simulator, all the response headers are intact, but when I test it on my Android device (Android 11 with Sense, SDK 6), the response headers are wrong and only has 4 headers (cache-control,content-length,content-type,expiresinstead of everything from the server ([ 'alt-svc', 'cache-control', 'content-length', 'content-type', 'date', 'expires', 'function-execution-id', 'qr-exp', 'server', 'status', 'survey-code', 'x-cloud-trace-context' ]). Even the console log results are displayed differently, on Android it's just comma-separated, but on the simulator it's has the list brackets ([]). The code I'm using on both devices are identical.

 

To reproduce this, try fetching any random URL with some response headers (e.g. google.com), and log the header keys/values, for google, on simulator I got 

[ 'alt-svc', 'bfcache-opt-in', 'cache-control', 'content-encoding', 'content-length', 'content-type', 'date', 'expires', 'p3p', 'server', 'status', 'strict-transport-security', 'x-frame-options', 'x-xss-protection' ], and on Android I got cache-control,content-length,content-type,expires.
 
Below is the code I used to test this:
 

 

 

let url = "https://www.google.com/";
fetch(url)
  .then(response => {
    console.log("response from", url, Array.from(response.headers.keys());
  });

 

 

 

To me, the only logical explanation is either I missed something very obvious or that this is a really annoying bug. Unless someone at Fitbit decided to intentionally design this? Any help would be greatly appreciated.

Best Answer
0 Votes
1 REPLY 1

This must be some kind of restriction in Chromium webview on Android. We aren't doing anything to restrict this.

Best Answer
0 Votes