3

I have developed a simple REST api using NODE and EXPRESS. And I already have a web-app(browser) and a native mobile application. Now I need to check if the incoming request is from web-browser or from native application.

I have successfully detected the device for incoming request coming from browser via USER-AGENT.

Prata
  • 1,250
  • 2
  • 16
  • 31

2 Answers2

0

I will suggest using the Host header. For example: If your web application is hosted at example.com then all requests will have Host header set to example.com. In your mobile application, you can manually set all request headers to have a different Host header like Host:app.example.com.

A good practice to have limited set of hostnames that accepted by the server.

Make sure you do not tight any security logic to that header. Every HTTP client can fake/override that value.

Ihor
  • 461
  • 4
  • 8