Workers - get operating system


#1

How in workers I can get the operating system? and browser type also?


#2

This is achieved by getting the User Agent, it’s a header in the request. Note that it can be spoofed easily, that string isn’t verified like the IP for example.


#3

For User Agent:
request.headers.get('user-agent')


#4

As already stated, can be easily spoofed - You will be better off using a npm module like https://github.com/faisalman/ua-parser-js however to get a detailed breakdown