# DevSpace device networking

Connect a physical device through a restricted ingestion proxy with Microsoft Dev Tunnels, Cloudflare Quick Tunnels, or ngrok.

Source: https://appportal.io/docs/getting-started/devspaces-networking

A phone's `localhost` points to the phone. Use an HTTPS tunnel to reach DevSpace on your
computer, and configure the SDK with that tunnel's base URL.

## Start the ingestion proxy

Keep DevSpace's web UI, management API, and MCP on loopback: they have no user login.
Expose only telemetry ingestion through the supplied [ingestion proxy](https://appportal.io/downloads/devspace/ingestion_proxy.py).
You need Python 3, a running DevSpace container, and a local application key.

In a separate terminal:

```sh
python3 ingestion_proxy.py
# For a collector on another host port:
DEVSPACE_UPSTREAM_PORT=8081 python3 ingestion_proxy.py
```

The proxy listens on `127.0.0.1:18080` and forwards telemetry to the loopback collector
(default port 8080). It rejects web, management, and MCP routes. Missing or invalid application
keys return 401. Keep the key private and use development data.

Check the boundary before starting a tunnel:

```sh
curl -i -X POST -H 'Content-Type: application/json' --data '[]' \
  http://127.0.0.1:18080/v1/ingest/events  # expected 401
curl -i http://127.0.0.1:18080/mcp         # expected 404
curl -i http://127.0.0.1:18080/api/apps    # expected 404
curl -i http://127.0.0.1:18080/            # expected 404
```

Choose one tunnel provider below. Forward **port 18080**, never the combined DevSpace port.
Repeat the checks against the public HTTPS URL before connecting your app.

## Microsoft Dev Tunnels

Install the CLI and sign in with a Microsoft/Entra ID or GitHub account:

```sh
brew install --cask devtunnel
devtunnel user login
devtunnel host -p 18080
```

Tunnels are private by default. Native SDK requests need their own tunnel authentication;
browser sign-in does not authenticate them. A client that supports custom headers can send
`X-Tunnel-Authorization: tunnel <CONNECT_TOKEN>`.

The .NET SDK's embedded Apple/Android ingestion transport does not expose custom headers.
For that transport, use an anonymous tunnel **only to the application-key-protected proxy**:

```sh
devtunnel host -p 18080 --allow-anonymous
```

Use the printed HTTPS URL as the SDK endpoint. A host command without an existing tunnel ID
creates a temporary tunnel that is removed when hosting stops. Stop with Ctrl-C, then stop the
proxy with Ctrl-C. `--protocol https` selects an HTTPS upstream; leave it out for this HTTP proxy.
No router port forwarding is needed.

[Microsoft setup](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started),
[authentication](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/security),
[CLI commands](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/cli-commands).

## Cloudflare Quick Tunnels

Install `cloudflared`. Quick Tunnels do not require a Cloudflare account or domain:

```sh
brew install cloudflared
cloudflared tunnel --url http://localhost:18080
```

Use the printed `https://<RANDOM>.trycloudflare.com/` URL as the SDK endpoint. It changes on a new
Quick Tunnel and stops working when `cloudflared` stops. Quick Tunnels are for development and
have no uptime guarantee. Interactive email/PIN protection cannot authenticate native SDK requests;
keep application-key validation on the ingestion proxy.

Stop `cloudflared` with Ctrl-C, confirm the URL is unavailable, then stop the proxy with Ctrl-C.

[Quick Tunnels](https://developers.cloudflare.com/tunnel/get-started/quick-tunnels/),
[installation](https://developers.cloudflare.com/tunnel/downloads/).

## ngrok

Install the ngrok agent and use your ngrok account's agent auth token:

```sh
brew install ngrok
ngrok config add-authtoken <YOUR_AGENT_AUTHTOKEN>
ngrok http 18080
```

Token setup saves the agent credential locally. Keep it out of source control and shared logs.
Use the displayed HTTPS forwarding URL as the SDK endpoint. The free plan assigns a development
domain to your account; the agent must remain running to forward requests. Agent authentication
does not authenticate clients of the public endpoint, so keep application-key validation enabled.

The browser warning targets HTML traffic; programmatic API requests are unaffected. Interactive
OAuth/browser protection does not authenticate a native SDK. Check the provider's current plan limits.

Stop the agent with Ctrl-C, confirm forwarding stops, then stop the proxy with Ctrl-C. The assigned
domain and saved agent token remain in your ngrok account/configuration.

[ngrok quickstart](https://ngrok.com/docs/share-localhost/quickstart),
[plan limits](https://ngrok.com/docs/pricing-limits/free-plan-limits).

## Configure the SDK and check delivery

Set the SDK base endpoint to the provider's HTTPS URL, for example `https://<PROVIDER_HOST>/`,
and retain the DevSpace application key. Rebuild your app if its endpoint is a build-time setting.
Do not append an ingestion suffix or put the key in a URL.

Run the app with consent granted, perform an action, and find the new session in DevSpace.
If it is missing, check the app's endpoint and key, SDK diagnostics, and that Docker, the proxy,
and the tunnel agent are all running. A new temporary URL requires updating the app configuration.
Stop the tunnel and proxy when finished; the local DevSpace workspace can keep running.
