Skip to content

Preview & Authentication

The Daytona SDK provides a method to generate preview links for Sandboxes. A preview link’s schema consists of the port and Sandbox ID (e.g. https://3000-sandboxid.proxy.daytona.works).

Any process listening for HTTP traffic on ports 3000–9999 can be previewed.

To fetch the preview link and the authorization token for a specific port, you can simply use the SDK method:

preview_info = sandbox.get_preview_link(3000)
print(f"Preview link url: {preview_info.url}")
print(f"Preview link token: {preview_info.token}")

See: get_preview_link (Python SDK), getPreviewLink (TypeScript SDK)

Authentication

If the Sandbox has its public property set to true, these links will be publicly accessible, otherwise the preview link will be available only to the Sandbox Organization users.

For programmatic access, use the authorization token to access the preview URL:

Terminal window
curl -H "x-daytona-preview-token: vg5c0ylmcimr8b_v1ne0u6mdnvit6gc0" \
https://3000-sandbox-123456.proxy.daytona.work

Warning Page

When opening the preview link in a browser, a warning page will be shown for the first time. This warning serves as a security measure to inform users about the potential risks of visiting the preview URL.

The warning page will only be shown when loading the preview link in a browser.

To avoid this warning you can do one of the following: