Skip to content

Instantly share code, notes, and snippets.

@disintegrator
Last active August 12, 2024 10:20
Show Gist options
  • Save disintegrator/6f87feb54432e5dda0927acb290321bb to your computer and use it in GitHub Desktop.
Save disintegrator/6f87feb54432e5dda0927acb290321bb to your computer and use it in GitHub Desktop.
Setting User-Agent header on the browser has surprising results
// Chromium bug: https://issues.chromium.org/issues/40450316
const headers = new Headers();
headers.set("user-agent", "fancy/1.0");
console.log(headers.get("user-agent") == null);
// Prints: false
const req = new Request('');
req.headers.set("user-agent", "fancy/1.0");
console.log(req.headers.get("user-agent") == null);
// Prints: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment