Access your tailnet from CodeSandbox

CodeSandbox is an online code editor and IDE for rapid web development.

Tailscale can be installed within a CodeSandbox Repository environment to be able to access private resources securely. You can develop your application as if it were hosted in the same network as your other services, without compromising security.

Tailscale works in CodeSandbox Repository environments by adding a container to a Dockerized application setup (for example, using docker-compose). The additional container runs the Tailscale client and provides networking for the other containers.

Integration

Follow the CodeSandbox instructions for getting Tailscale working in a CodeSandbox Repository.

You’ll need to:

  1. Create an auth key in the Keys page of the Tailscale admin console. The key type should be reusable, ephemeral, and pre-authorized. You may also want to make the key type tagged, so your CodeSandbox environments are automatically labeled and granted access that is controlled via Tailscale ACLs.

  2. Add the auth key as a CodeSandbox environment variable, named TS_AUTHKEY.

  3. Add the tailscale/tailscale Docker image as an additional service beside your application.

Authorization

Authenticate to Tailscale from your workspace by referencing the TS_AUTHKEY environment variable in your Docker tasks when you start Tailscale. For example:

docker-compose exec tailscale tailscale up \
  --authkey=${TS_AUTHKEY} --accept-routes --hostname=csb-${HOSTNAME}