Subdomain/Region
subdomain region local URLs SDK configuration dynamic DNS offline accessWhen you start the CLI the services are exposed similarly to the way they are exposed in the cloud. For instance, the following information is shown on your terminal after running nhost up
> nhost up...URLs:- Postgres: postgres://postgres:postgres@localhost:5432/local- Hasura: https://local.hasura.local.nhost.run- GraphQL: https://local.graphql.local.nhost.run- Auth: https://local.auth.local.nhost.run- Storage: https://local.storage.local.nhost.run- Functions: https://local.functions.local.nhost.run- Dashboard: https://local.dashboard.local.nhost.run- Mailhog: https://local.mailhog.local.nhost.run
SDK Configuration: Subdomain: local Region: localThere you can see the various URLs you can use to access each service plus the region and subdomain you can use to configure the SDK:
// Create a new Nhost client for local development.const nhost = new NhostClient( { region: 'local', subdomain: 'local' })The domains in the URLs above will all return the IP address for localhost, 127.0.0.1, which should suffice for most development environments. For instance:
> host local.auth.local.nhost.runlocal.auth.local.nhost.run has address 127.0.0.1However, those URLs are powered by a dynamic DNS that can return any IPv4 address you need, you just need to replace the subdomain local with a subdomain that contains the 4 octets of the IPv4 address you want separated by -. For instance:
> host 192-168-100-1.auth.local.nhost.run192-168-100-1.auth.local.nhost.run has address 192.168.100.1
> host 10-10-1-108.auth.local.nhost.run10-10-1-108.auth.local.nhost.run has address 10.10.1.108This is useful if you need to connect to your environment from a different device, a VM or a mobile device emulator.
To make use of this functionality you can start your development environment after setting the environment variable NHOST_LOCAL_SUBDOMAIN or passing the flag --local-subdomain :
> export NHOST_LOCAL_SUBDOMAIN=192-168-1-1-8 # either this or --local-subdomain 192-168-1-108> nhost --local-subdomain 192-168-1-108 up...Nhost development environment started.URLs:- Postgres: postgres://postgres:postgres@localhost:5432/local- Hasura: https://192-168-1-108.hasura.local.nhost.run- GraphQL: https://192-168-1-108.graphql.local.nhost.run- Auth: https://192-168-1-108.auth.local.nhost.run- Storage: https://192-168-1-108.storage.local.nhost.run- Functions: https://192-168-1-108.functions.local.nhost.run- Dashboard: https://192-168-1-108.dashboard.local.nhost.run- Mailhog: https://192-168-1-108.mailhog.local.nhost.run
SDK Configuration: Subdomain: 192-168-1-108 Region: localRun `nhost up` to reload the development environmentRun `nhost down` to stop the development environmentRun `nhost logs` to watch the logsNow you can configure the SDK with:
// Create a new Nhost client for local development.const nhost = new NhostClient( { region: 'local', subdomain: '192-168-1-108' })Offline access
Section titled “Offline access”All the URLs in this document are resolved by a public DNS, which means you need Internet access to resolve them. If you need to use any of those URLs without Internet access you can add them to your /etc/hosts file. For instance:
> cat /etc/hosts### Host Database## localhost is used to configure the loopback interface# when the system is booting. Do not change this entry.##127.0.0.1 localhost255.255.255.255 broadcasthost# ::1 localhost
127.0.0.1 local.auth.local.nhost.run local.storage.local.nhost.run ...Just start with the IP you want to resolve followed by all the entries you need separated by spaces.