Prerequisites
- Blaxel CLI installed and authenticated with
bl login - Node.js 18 or later
@blaxel/coreinstalled in your project withnpm install @blaxel/core
1. Understand the architecture
Running Astro inside a Blaxel Sandbox requires a few adjustments:- Astro normally binds to localhost
- Blaxel exposes services through preview URLs
- Astro must accept external connections and all hosts
astro.config.mjs with host: "0.0.0.0" and allowedHosts: true, then expose the Astro development server through a Blaxel preview URL.
2. Build the sandbox image
Create aDockerfile:
3. Configure Astro
Createastro.config.mjs to allow external connections:
4. Create the entrypoint
Createentrypoint.sh to start the sandbox API and Astro development server:
5. Configure and deploy the image
Createblaxel.toml beside the Dockerfile:
6. Create or reuse a sandbox
7. Configure preview response headers
Astro development servers work well with permissive CORS headers when accessed through a preview URL:8. Create the preview and token
Astro runs on port4321. Create a private preview for that port:
9. Start and monitor the development server
If you do not use the entrypoint script, start Astro programmatically:10. Access the Astro application
Once the server is running, open:11. Run the complete example
Resources
Real-time previews
Configure public and private preview URLs for sandbox services.
Sandbox images
Build and manage reusable Blaxel Sandbox images.