typebot.io icon indicating copy to clipboard operation
typebot.io copied to clipboard

Embed Code References Non-Existent web.js Version 0.3.17, Causing 404 Errors and JavaScript TypeErrors

Open ednargocat opened this issue 1 year ago • 0 comments

``When embedding a self-hosted Typebot instance on a website, the generated embed code references a non-existent version of the Typebot JavaScript library (web.js version 0.3.17). This results in 404 errors when attempting to load the script, leading to subsequent JavaScript TypeError issues that prevent the Typebot from functioning correctly.

To Reproduce

Steps to reproduce the behavior:

Set Up Self-Hosted Typebot:

Deploy Typebot on your server following the official Docker deployment instructions. Ensure that the Typebot services (typebot-builder, typebot-viewer, typebot-db) are running without errors. Generate Embed Code:

Access the Typebot admin dashboard for your self-hosted instance (e.g., https://bot.yourdomain.com). Navigate to the section where you can generate the embed code for a specific Typebot (e.g., quiz-abc123). Use the Embed Code on Your Website:

Insert the provided embed code into your website's HTML where you want the Typebot to appear. Self-Hosted Embed Code Example:

Load the Webpage:

Open the webpage where the embed code is placed. Open the browser's Developer Tools (Press F12 or Ctrl + Shift + I). Observe Console Errors:

Navigate to the Console tab. Notice the following errors:

Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at share-modal.js:1:135 Failed to load resource: the server responded with a status of 404 () https://cdn.jsdelivr.net/npm/@typebot.io/[email protected]/dist/web.js

Expected behavior

The embed code should reference a valid and existing version of the Typebot JavaScript library (web.js). Loading the correct script should eliminate the 404 errors and prevent JavaScript TypeError issues, allowing the Typebot to function seamlessly on the website.

Actual behavior

The embed code references web.js version 0.3.17, which does not exist on the CDN (jsDelivr). This results in a 404 error when attempting to load the script:

Failed to load resource: the server responded with a status of 404 () https://cdn.jsdelivr.net/npm/@typebot.io/[email protected]/dist/web.js

Subsequently, the missing script leads to a JavaScript error: Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at share-modal.js:1:135

Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at share-modal.js:1:135 Failed to load resource: the server responded with a status of 404 () https://cdn.jsdelivr.net/npm/@typebot.io/[email protected]/dist/web.js

Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at share-modal.js:1:135 Failed to load resource: the server responded with a status of 404 () https://cdn.jsdelivr.net/npm/@typebot.io/[email protected]/dist/web.js

Environment

Typebot Deployment: Self-hosted using Docker on Ubuntu Server

Additional context

Temporary Fix Implemented:

Changing the web.js version in the embed code from 0.3.17 to 0.3 resolved the immediate issue: html

However, the embed code generation still outputs the incorrect version (0.3.17), which could affect future deployments or new embed codes. CORS Configuration:

Proper CORS settings have been applied to the DigitalOcean Spaces bucket to allow communication between the website and the self-hosted Typebot API. Docker Containers Status:

All Typebot-related Docker containers are running without errors. Network Requests:

The web.js script fails to load due to a 404 error, as detailed in the console logs.

ednargocat avatar Oct 21 '24 15:10 ednargocat