sandbox_wire
Switches a declared name between your process in the box and externalBaseUrl, declares a new name on a running box, or points a name at another box or a published version.
| Input | Output |
|---|---|
id, service, and mode (box or external); or port with an optional targetPort; or port with fromBox and an optional fromPort (a link); or port with version and optional containerPort and env (a published version); or scenePaths instead of a service |
wiring (externalBaseUrl, entry, services[{name, port, targetPort, address, mode, web}]), dns; for a link, links[{name, port, fromBox, fromPort, fromStatus, active, opened, failed}]; for a version, service (with its run) and next |
Only needed when the box has an externalBaseUrl (passed to sandbox_start or inherited from its environment), or to declare a name on a running box.
mode: "box":name:portreaches your own process on the service'stargetPortin the box.mode: "external":name:portforwards HTTP toexternalBaseUrlagain. Fails when the box has noexternalBaseUrl: then every declared service already reaches your process in the box and there is nothing to wire; to send names to your dev, start a box withenvironment(which brings itsexternalBaseUrl) orexternalBaseUrl.- Names that share a
targetPortare one process and switch together. - Switching only rewrites routing rules; boxd holds no port for it, so your process can already be running. Connections already open stay open, and new ones follow the new mode.
port, with an optionaltargetPort: declaresserviceas a new host name on the running box. It gets its own address and resolves from then on like the names given at start, andname:portreachestargetPort(default:port; required whenportis 80 or 9095).modeis ignored: the new name takes the mode of the names already on itstargetPort, otherwise it startsexternalon a box with anexternalBaseUrlandboxon one without. The name is recorded with the box: it appears insandbox_status.servicesand survives a boxd restart. Withoutwebit gets no URL; withweb: true, a box made from the new image gets a working URL for this service, even if it is not the first one. On older boxes, adding a second web service this way returns 409 with guidance to start a new box. Address ranges cannot be added this way. A name that is now a link or one of the environment's addresses is taken over in place on boxes with thetake-overfeature (Taking over a link or an environment address); on older boxes an environment address keeps going through the connector and a link name fails with 409. Giving an existing name a differentportortargetPortmoves it.targetPortwithoutportfails with 400.web: truewithoutport: marks a service already declared asweb, so thatwebUrland the app's Use it button open it. It does not decide what asandbox_reviewcard opens: that call names it withopen(andportforweb).modeis optional: omit it to keep the current routing mode, or provide one to switch routing too. On a new box, every web service has a working URL: the first usessceneUrl, and the others have their own URLs. On an older box, marking a second service web returns 409 with guidance to start a new box.portwithfromBox, and an optionalfromPort: declares a link to another of your boxes, or re-points an existing link (sameserviceandport). The result is then{ "links": [...] }, every link of the box. See Links to other boxes.portwithversion, and optionalcontainerPortandenv: declares the name on the running box and starts that published version under it, replacing whatever version ran there before. The result is{ "service": {...}, "next": "..." }, the service with itsrun. See Run a published version.scenePaths(instead ofservice): path prefixes onsceneUrlthat the box forwards toexternalBaseUrl, such as["/api"], keeping the path. A page loaded fromsceneUrlthen calls the environment's API same-origin, so the environment needs no CORS entry for the box's URL (allowing*.box.parallelsandbox.comthere would let every account's boxes in). Each call replaces the list;[]clears it. Paths start with/,/_sbxis the box's own, and the box needs anexternalBaseUrl. The result is the wiring table with the paths.- Boxes started before
targetPortshipped run an older boxd that does not support it: there, atargetPortdifferent fromportfails with 409 and a message saying so. Start a new box, or declare the service on the port your process listens on, withouttargetPortand not on 80 or 9095. - The return value is the whole wiring table, also in
sandbox_status.wiring:externalBaseUrl,entry(the first service, whichsceneUrlopens) and every service with itsport,targetPort,address(the name's address in the box; address ranges have none),modeandweb; plusdns, each name the box answers itself with its address (declared services and the environment's host names). - Services inside one
docker composeproject also reach each other through the compose network.
Every tool and topic is listed in the tool reference.