I have a NodeJs app hosted on Heroku. As part of Authentication, I want to open a browser window when user accesses the /login route.
I am using Node's "open" library for this, and passing the URL as parameter. While this works on local machine and Node opens the browser window(with that URL), but it doesn't, when hosted on Heroku.
So, I'd like to understand if there's any limitation with Heroku platform in performing such action,and what other steps should I take to resolve this issue.
I have tried open and opener libraries.
Sample code with opener library.
var opener = require("opener");
url = 'https://exampleapp.herokuapp.com';
opener(url);
return;
To redirect the user to a page after a certain even within the same page you can do a simple (assuming you're using express with Nodejs):
res.redirect()
orres.download()
if you would like the user to be able to download an item instead.Else, if you would like a new window to open with the new page (not overriding the previous page they were on) you will need an extra module to do so as express does not handle browser side code: I recommend Puppeteer with this example code:
The
{headless: false}
parameter in the functionpuppeteer.launch()
function will open a new tab in the users browser.