Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a custom hostname while creating the ngrok instance programatically #258

Open
subhanahmed047 opened this issue Dec 6, 2021 · 7 comments

Comments

@subhanahmed047
Copy link

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,
 });
@philnash
Copy link
Collaborator

philnash commented Dec 6, 2021

What happens when you try to set up the tunnel like that? Is there an error?

@mquinnv
Copy link

mquinnv commented Dec 6, 2021

can confirm that hostname works for the whitelabel/CNAME option. just leave off subdomain

@subhanahmed047
Copy link
Author

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.

@philnash
Copy link
Collaborator

philnash commented Dec 6, 2021

Thanks @subhanahmed047, I'll take a look.

@mquinnv
Copy link

mquinnv commented Dec 7, 2021

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

@philnash
Copy link
Collaborator

@subhanahmed047 Can you check if it works with a fully qualified hostname?

@itsib
Copy link

itsib commented Jul 12, 2024

I changed filed domain to hostname, it works. Thanks @mquinnv !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants