A fork of codesandbox-client that provides pre-built packages of the Sandpack bundler optimized for self-hosting with LibreChat and other applications.
Self-hosting the Sandpack bundler gives your LibreChat instance several advantages:
# Pull the image
docker pull ghcr.io/librechat-ai/codesandbox-client/bundler:latest
# Run the container
docker run -p 8080:80 ghcr.io/librechat-ai/codesandbox-client/bundler:latest
bundler.zip from the Releases pageLibreChat can use your self-hosted bundler for Artifacts by setting the SANDPACK_BUNDLER_URL environment variable:
# In your LibreChat .env file or environment configuration
SANDPACK_BUNDLER_URL=http://your-bundler-url
That’s it! LibreChat will now use your self-hosted bundler for code execution.
When hosting the bundler files, you’re responsible for configuring your web server appropriately. Our Docker image includes a basic Nginx configuration, but if you’re serving the files yourself, you’ll need to handle:
The bundler needs to communicate with your application, which typically requires CORS headers. You’re responsible for configuring these based on your security requirements:
Access-Control-Allow-Origin: *) for testingDifferent file types in the bundler may require specific content type settings:
.worker.js) in particular need to be served with appropriate JavaScript MIME typesSecurity is entirely your responsibility when self-hosting:
You can enhance performance through:
If you encounter issues:
If you want to build the bundler yourself:
yarn install to install dependenciesyarn build:depsyarn start to build codesandbox-browserfs dependency (Then exit)lerna run build --scope @codesandbox/common --scope @codesandbox/components --scope appyarn build:sandpackwww directory