Passing a custom hostname while creating the ngrok instance programatically
I'm trying to create a ngrok instance with a custom hostname, but It looks like the ngrok options object doesn't accept the hostname, so how do we create an instance that is using our custom domain rather than default ngrok.io?
Here is how I'm doing it:
await ngrok.connect({
authtoken: TOKEN,
hostname: 'mydomain.io', // this doesn't exist
subdomain: uuid,
region: 'au',
port,
});
What happens when you try to set up the tunnel like that? Is there an error?
can confirm that hostname works for the whitelabel/CNAME option. just leave off subdomain
running the following piece of code:
await ngrok.connect({
port,
region,
authtoken,
hostname: '*.mydomain.io', // this is registered in ngrok dashboard and CNAME DNS records are also set
});
I get the following error:
TypeError: Cannot read property 'body' of undefined
I raised the issue because I also noticed that the types for Ngrok.Options object doesn't contain a hostname property either.
Thanks @subhanahmed047, I'll take a look.
my code that works in webpack devServer onListening is:
server.public = await ngrok.connect({
addr: localPort,
hostname: process.env.NGROK_DOMAIN,
authtoken: process.env.NGROK_AUTHTOKEN,
})
where hostname is my exact entry in ngrok of the form host.domain.net. i'm not sure why the local port is called addr, perhaps you can specify the interface as well as the port
@subhanahmed047 Can you check if it works with a fully qualified hostname?