Mocko Cloud

Local Tunnels

A Local Tunnel connects a port on your machine to your Cloud project. Requests to your public host reach the service you are running locally, and your mocks still apply on top. It is a way to put a real, in-progress backend behind the same URL your team already uses.

Local Tunnels are currently in beta.

Why tunnel instead of proxy

A project's proxy URL reaches a backend that is already accessible on the internet. A tunnel is for the backend that is not: a service on localhost behind your firewall or NAT. The tunnel opens a secure connection outward from your machine, so the Cloud can forward requests to it without you exposing a port.

Because your mocks sit in front of the tunnel, you can override individual endpoints of a local service without touching its code, and watch every request that flows through in Request Logs.

Install the tunnel client

The tunnel runs as a small command-line client, installed globally from npm:

$npm install -g @mocko/tunnel

It exposes two equivalent commands, mocko-tunnel and the shorter mlt.

Get your tunnel token

A token authorizes the client to connect to your project. Open the Tunnels view in the control panel, enable Local Tunnel for the project, and copy the generated token. The token belongs to the project, so anyone with it can tunnel into that host: treat it like a secret.

Open the tunnel

Point the client at the local port you want to expose. If your service runs on port 8080:

$mocko-tunnel 8080

The client prompts for the token the first time. You can also pass it directly, which is handy in scripts:

$mocko-tunnel 8080 --token <your-tunnel-token>

While the tunnel is open, requests to your public host that no mock handles are delivered to your local service on port 8080. Stop the client and the tunnel closes.

A tunnel and a proxy URL both handle the requests your mocks do not. Reach for the tunnel when the backend only exists on your machine, and for the proxy URL when it is already reachable on the network.