exposePort() method provides a public HTTPS URL that maps directly to a specific port running inside your sandbox container. Fermion automatically supports ports 3000, 1337, and 1338, allowing you to host web servers, APIs, or other services securely and access them from anywhere.
When you start a server inside your sandbox, using commands like node server.js or npm run dev, you can call exposePort(port) to instantly retrieve a URL in the format https://{subdomain}-{port}.run-code.com. This enables you to preview, test, and share live services running within your sandbox without any manual networking setup or tunneling.
exposePort(port)
Description:
Returns the public HTTPS URL for a specific port in the sandbox. The sandbox automatically exposes ports 3000, 1337, and 1338 publicly.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| port | 3000 | 1337 | 1338 | Yes | Port number (must be one of these three) |
Promise<string> - Public HTTPS URL (format: https://{subdomain}-{port}.run-code.com)
Example:
