Reputation: 489
I have a nodejs code where at some point it uses a new tab for showing results.I got npm-open where it show my result in a new tab of the browser.But when i deploy it in a linux server, its neither opening a new tab nor throwing any error?
open( req.protocol + '://' + req.get('host')+"/view-document/?logos="+ logos+"&comp_name="+result_3[0].name +"&emp_name="+empname+"&start_date="+sdates+"&end_date="+edates+"&position="+designation+"&template=template1"+"&emp_id="+emp_id+"&issue_date="+issue_date+"&title="+title, function (err) {
if ( err ) {
res.redirect("/view-document/?logos=" + logos+"&comp_name="+result_3[0].name +"&emp_name="+empname+"&start_date="+sdates+"&end_date="+edates+"&position="+designation+"&template=template1"+"&emp_id="+emp_id+"&issue_date="+issue_date+"&title="+title);
return;
}
});
Upvotes: 0
Views: 398
Reputation: 7983
How could it?
The open
command is a way to make your script interact with the OS it is running on, telling it to open a URL, image, etc. If you run your script on your local machine, this is fine and works as expected.
If you run your script on a server, there is no way it can communicate its request to your local machine. Think about it – should a random webpage/server have the ability to interact with the OS on client machines?
To make something like this work, you will need to split your script into two parts:
open
commandUpvotes: 2