how to check request is coming from node-webkit browser

building a app which will run under node-webkit window and normal chrome/safari browser, but what to turn OFF some native features in non node-webkit browser, but i am unable to check which browsers is requesting the page, so that i can send customised response for normal browser.
NODE_WEBKIT BROWSER REQUEST CHECKING

Submitted by surinder83singh On Thursday, 20 April 2017.
Category: Node-Webkit

[RESOLVED]

0
1 Answers.
 
Super User
crooker

Re:how to check request is coming from node-webkit browser

set user-agent in package.json (more info) as bellow


.... 
//"node-remote": "http://localhost", 
"user-agent": "::nw_native:: %name %ver %nwver %webkit_ver %osinfo", 
....


then in express app use middleware to detect nw_native as bellow

app.use(function(req, res, next) { 
	res.locals.isNWBrowser = req.headers['user-agent'].indexOf("nw_native") > 0; 
        next(); 
})


now u can use isNWBrowser in express template as bellow
<% if(isNWBrowser){ %> 
<script> 
var gui = require("nw.gui"); 
gui.Window.get().maximize(); 
</script> 
<% } %>
Submitted by Super User On Thursday, 20 April 2017
0
This Answer has been Chosen as Best Answer
Question is marked as resolved.