A Nuxt module for automatically running localtunnnel to externally expose your development instance of Nuxt to the outside world.
Allows full configuration of all localtunnel configuration options including https
npx nuxi@latest module add nuxt-localtunnelEdit your nuxt.config.ts and add the @nuxtus/nuxt-localtunnel module:
modules: [
'@nuxtus/nuxt-localtunnel'
],
localtunnel: {} // Localtunnel config options go here (see below)Then start Nuxt as normal npm run dev, you will be given an extra (external URL to reach your development site).
All localtunnel configuration options are accepted via the localtunnel property of the nuxt.config.ts file:
port(number) The local port number to expose through localtunnel.subdomain(string) Request a specific subdomain on the proxy server. Note You may not actually receive this name depending on availability.host(string) URL for the upstream proxy server. Defaults tohttps://localtunnel.me.local_host(string) Proxy to this hostname instead oflocalhost. This will also cause theHostheader to be re-written to this value in proxied requests.local_https(boolean) Enable tunnelling to local HTTPS server.local_cert(string) Path to certificate PEM file for local HTTPS server.local_key(string) Path to certificate key file for local HTTPS server.local_ca(string) Path to certificate authority file for self-signed certificates.allow_invalid_cert(boolean) Disable certificate checks for your local HTTPS server (ignore cert/key/ca options).display_qr(boolean) Display QR code for the newly generated URL.
Refer to tls.createSecureContext for details on the certificate options.
You can override configuration options using environment variables. This is particularly useful for keeping the same subdomain across development sessions without modifying your config file:
LOCALTUNNEL_SUBDOMAIN- Override the subdomain settingLOCALTUNNEL_HOST- Override the host setting
Example usage:
# Keep the same subdomain every time you run dev
LOCALTUNNEL_SUBDOMAIN=myappsubdomain npm run dev
# Use a custom localtunnel server
LOCALTUNNEL_HOST=https://custom-server.com npm run devEnvironment variables take precedence over config file settings.
- Run
npm run dev:prepareto generate type stubs. - Use
npm run devto start playground in development mode.