curl --request GET \
--url https://api.example.com/widget/chat-widget.jsRetrieve the compiled chat widget JavaScript bundle
curl --request GET \
--url https://api.example.com/widget/chat-widget.jsGET /widget/chat-widget.js
application/javascript; charset=utf-8
// Compiled widget bundle content
(function() {
// Widget initialization code
// ...
})();
{
"error": "Widget bundle not found. Build the widget with `npm run build --workspace widget`."
}
curl https://your-api-domain.com/widget/chat-widget.js
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1>Welcome to my website</h1>
<!-- Load the chat widget -->
<script src="https://your-api-domain.com/widget/chat-widget.js"></script>
<!-- Initialize the widget -->
<script>
window.ChatWidget.init({
apiUrl: 'https://your-api-domain.com',
apiKey: 'your-api-key-here',
position: 'bottom-right'
});
</script>
</body>
</html>
const script = document.createElement('script');
script.src = 'https://your-api-domain.com/widget/chat-widget.js';
script.async = true;
script.onload = () => {
window.ChatWidget.init({
apiUrl: 'https://your-api-domain.com',
apiKey: 'your-api-key-here'
});
};
document.head.appendChild(script);
Cache-Control: public, max-age=300, immutable (5 minute cache)Cache-Control: no-store (no caching)npm run build --workspace widgetWIDGET_BUNDLE_PATH environment variable