Skip to content

Make your localhost apps public by tunneling subdomains to them.

License

Notifications You must be signed in to change notification settings

ivangabriele/publichost

Repository files navigation

FirePT Logo

PublicHost

Tunneling subdomains to your localhost applications.

NPM Version AGPL-3.0 license CI Check Workflow CI E2E Workflow



Why PublicHost?

Because ngrok but open-source and free.

Features

  • PublicHost Server
    • Basic API Key Authentication
  • PublicHost Client
    • CLI commands
    • Node.js SDK

How it works

To be updated.

Installation

CLI

npm install -g publichost

Usage

ph --help

Node.js SDK

npm install -E publichost

Koa Example

import Koa from 'koa'

const { PORT, PUBLICHOST_API_KEY, PUBLICHOST_HOST, PUBLICHOST_SUBDOMAIN } = process.env

const app = new Koa()

app.listen(PORT, () => {
  console.info('[My Amazing Localhost App]', `Server listening on port ${PORT}.`)

  startPublicHost(PUBLICHOST_HOST, PUBLICHOST_SUBDOMAIN, PUBLICHOST_API_KEY, {
    localhostAppPort: PORT,
  })
})

Express Example

import express from 'express'

const { PORT, PUBLICHOST_API_KEY, PUBLICHOST_HOST, PUBLICHOST_SUBDOMAIN } = process.env

const app = express()

app.listen(PORT, () => {
  console.info('[My Amazing Localhost App]', `Server listening on port ${PORT}.`)

  startPublicHost(PUBLICHOST_HOST, PUBLICHOST_SUBDOMAIN, PUBLICHOST_API_KEY, {
    localhostAppPort: PORT,
  })
})