[GH-ISSUE #3978] [BUG]: AnythingLLM Embed Widget Not Working #2530

Closed
opened 2026-02-22 18:30:05 -05:00 by yindo · 2 comments
Owner

Originally created by @metakai1 on GitHub (Jun 10, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3978

How are you running AnythingLLM?

Docker (remote machine)

What happened?

🆘 AnythingLLM Embed Widget Not Working - Need Help!

Hey everyone! I'm having trouble getting the AnythingLLM embed chat widget to work on my website. Hoping someone here has seen this before! 🤔

My Setup:
• AnythingLLM running in Docker (mintplexlabs/anythingllm:latest)
• Container is healthy, main interface works perfectly at https://agent.innovatewith.ai
• Using Cloudflare Tunnel for SSL/routing
• Created embed in admin panel, got the embed code

The Problem:
• Embed widget script loads but no chat UI appears
• All API endpoints (/api/embed/{id}, /api/system) return HTML instead of JSON
• Even direct container access returns HTML for API routes
• Embed URL shows blank page with just basic HTML structure

What Works:
Main AnythingLLM interface (with login)
Chat functionality, workspaces, AI models
Widget script downloads (658KB)
Container logs show healthy backend

What Doesn't Work:
/api/embed/{embed-id} returns HTML instead of embed config
Widget creates session ID but no UI elements
Browser console shows no errors

Tried:
• Container restart
• Multiple embed IDs
• Direct container access (bypassing tunnel)
• Different embed configurations

Has anyone successfully deployed AnythingLLM embeds? Is there a specific version that works better? Or any special configuration I'm missing?

Would really appreciate any insights! 🙏

Container Info:

CONTAINER ID   IMAGE                      STATUS
9475f27771a2   mintplexlabs/anythingllm   Up 3 hours (healthy)

Thanks in advance! 🚀

Are there known steps to reproduce?

No response

Originally created by @metakai1 on GitHub (Jun 10, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/3978 ### How are you running AnythingLLM? Docker (remote machine) ### What happened? **:sos: AnythingLLM Embed Widget Not Working - Need Help!** Hey everyone! I'm having trouble getting the AnythingLLM embed chat widget to work on my website. Hoping someone here has seen this before! :thinking: **My Setup:** • AnythingLLM running in Docker (`mintplexlabs/anythingllm:latest`) • Container is healthy, main interface works perfectly at `https://agent.innovatewith.ai` • Using Cloudflare Tunnel for SSL/routing • Created embed in admin panel, got the embed code **The Problem:** • Embed widget script loads but no chat UI appears • All API endpoints (`/api/embed/{id}`, `/api/system`) return HTML instead of JSON • Even direct container access returns HTML for API routes • Embed URL shows blank page with just basic HTML structure **What Works:** :white_check_mark: Main AnythingLLM interface (with login) :white_check_mark: Chat functionality, workspaces, AI models :white_check_mark: Widget script downloads (658KB) :white_check_mark: Container logs show healthy backend **What Doesn't Work:** :x: `/api/embed/{embed-id}` returns HTML instead of embed config :x: Widget creates session ID but no UI elements :x: Browser console shows no errors **Tried:** • Container restart • Multiple embed IDs • Direct container access (bypassing tunnel) • Different embed configurations Has anyone successfully deployed AnythingLLM embeds? Is there a specific version that works better? Or any special configuration I'm missing? Would really appreciate any insights! :pray: **Container Info:** ``` CONTAINER ID IMAGE STATUS 9475f27771a2 mintplexlabs/anythingllm Up 3 hours (healthy) ``` Thanks in advance! :rocket: ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:30:05 -05:00
yindo closed this issue 2026-02-22 18:30:06 -05:00
Author
Owner

@timothycarambat commented on GitHub (Jun 10, 2025):

Not a bug and is instead 100% an implementation detail that is causing your issues.

Using Cloudflare Tunnel for SSL/routing

What are the rules for this (if any) the embed is served at https://agent.innovatewith.ai/embed/anythingllm-chat-widget.min.js so if JS files responses are not valid or that is not the URL you are using in the code snippet that could be an issue.

Additionally, the fact the API is returning HTML (likely the homepage content) it would appear the tunneling or paths are not being well defined due to this tunneling. Without a doubt this lies on the SSL/Tunnel config here and that is either causing CORS or routing issues whereever you are putting the embed snippet.

@timothycarambat commented on GitHub (Jun 10, 2025): Not a bug and is instead 100% an implementation detail that is causing your issues. > Using Cloudflare Tunnel for SSL/routing What are the rules for this (if any) the embed is served at `https://agent.innovatewith.ai/embed/anythingllm-chat-widget.min.js` so if JS files responses are not valid or that is not the URL you are using in the code snippet that could be an issue. Additionally, the fact the API is returning HTML (likely the homepage content) it would appear the tunneling or paths are not being well defined due to this tunneling. Without a doubt this lies on the SSL/Tunnel config here and that is either causing CORS or routing issues whereever you are putting the embed snippet.
Author
Owner

@xiao-chen-cz commented on GitHub (Oct 12, 2025):

I initially thought it might be a reverse proxy issue too, but testing the API endpoints directly inside the container (bypassing the proxy entirely) still returned HTML instead of JSON.

This proves the issue exists in the application itself, not in the proxy configuration. The fix I'm describing below resolves it without any proxy configuration changes.

The Problem
In /app/server/index.js around line 104, there's a catch-all route that intercepts ALL requests, including API calls:

javascriptapp.use("/", function (_, response) {
IndexPage.generate(response);
return;
});

This route is registered AFTER the API routes (around line 64), but because it uses app.use("/", ...) without calling next(), it matches every request path including /api/* and immediately returns the generated HTML index page.

The Fix
Modifying the catch-all route to check for API paths before serving HTML resolves the issue:
javascriptapp.use("/", function (req, response, next) {
// Allow API routes to pass through
if (req.path.startsWith("/api/") ||
req.path.startsWith("/setup-") ||
req.path.startsWith("/v1/")) {
return next();
}
IndexPage.generate(response);
return;
});

Symptoms I Experienced
Main interface works perfectly (login, chat, workspaces)
/api/ping returns JSON correctly
Other API endpoints like /api/setup-complete and /api/system/* return HTML instead of JSON
LLM provider settings page stuck on "-- loading available models --"
Browser console shows "Failed to fetch" errors for API endpoints

Environment
Docker deployment via Coolify with Traefik reverse proxy
AnythingLLM version 1.9.0 (latest tag, as of October 2025)
NODE_ENV=production

Workaround for Docker/Coolify Users
Until this is fixed in the codebase, I've implemented an automated fix using a cron job:
docker-compose.yml (in Coolify):
yamlservices:
anything-llm:
image: mintplexlabs/anythingllm
# ... other config ...
volumes:
- 'anythingllm-storage:/app/server/storage'
- 'anythingllm-hot:/app/collector/hotdir'
- 'anythingllm-outputs:/app/collector/outputs'
- '/data/coolify/services//fix-routing.sh:/usr/local/bin/fix-routing.sh:ro'
labels:
- traefik.http.services..loadbalancer.server.port=3001

Server-side cron job (runs every minute):

  • Detects when container restarts
  • Automatically applies the routing fix
  • Logs to /var/log/anythingllm-fix.log

Happy to share the complete setup scripts if anyone needs them.

Suggested Permanent Fix
The catch-all route in the source code should either:

  1. Use app.get("*", ...) instead of app.use("/", ...") to only catch GET requests for unmatched routes
  2. Check request paths and call next() for API routes (as shown above)
  3. Be moved to run AFTER all other routes are registered

This appears to be a production-mode specific issue since the catch-all is only active when NODE_ENV !== "development" (line 88 in /app/server/index.js).

Hope this helps identify and resolve the issue permanently!

@xiao-chen-cz commented on GitHub (Oct 12, 2025): I initially thought it might be a reverse proxy issue too, but testing the API endpoints directly inside the container (bypassing the proxy entirely) still returned HTML instead of JSON. This proves the issue exists in the application itself, not in the proxy configuration. The fix I'm describing below resolves it without any proxy configuration changes. **The Problem** In /app/server/index.js around line 104, there's a catch-all route that intercepts ALL requests, including API calls: javascriptapp.use("/", function (_, response) { IndexPage.generate(response); return; }); This route is registered AFTER the API routes (around line 64), but because it uses app.use("/", ...) without calling next(), it matches every request path including /api/* and immediately returns the generated HTML index page. **The Fix** Modifying the catch-all route to check for API paths before serving HTML resolves the issue: javascriptapp.use("/", function (req, response, next) { // Allow API routes to pass through if (req.path.startsWith("/api/") || req.path.startsWith("/setup-") || req.path.startsWith("/v1/")) { return next(); } IndexPage.generate(response); return; }); **Symptoms I Experienced** ✅ Main interface works perfectly (login, chat, workspaces) ✅ /api/ping returns JSON correctly ❌ Other API endpoints like /api/setup-complete and /api/system/* return HTML instead of JSON ❌ LLM provider settings page stuck on "-- loading available models --" ❌ Browser console shows "Failed to fetch" errors for API endpoints **Environment** Docker deployment via Coolify with Traefik reverse proxy AnythingLLM version 1.9.0 (latest tag, as of October 2025) NODE_ENV=production **Workaround for Docker/Coolify Users** Until this is fixed in the codebase, I've implemented an automated fix using a cron job: docker-compose.yml (in Coolify): yamlservices: anything-llm: image: mintplexlabs/anythingllm # ... other config ... volumes: - 'anythingllm-storage:/app/server/storage' - 'anythingllm-hot:/app/collector/hotdir' - 'anythingllm-outputs:/app/collector/outputs' - '/data/coolify/services/<service-id>/fix-routing.sh:/usr/local/bin/fix-routing.sh:ro' labels: - traefik.http.services.<service-name>.loadbalancer.server.port=3001 _**Server-side cron job (runs every minute):**_ * Detects when container restarts * Automatically applies the routing fix * Logs to /var/log/anythingllm-fix.log Happy to share the complete setup scripts if anyone needs them. **Suggested Permanent Fix** The catch-all route in the source code should either: 1. Use app.get("*", ...) instead of app.use("/", ...") to only catch GET requests for unmatched routes 2. Check request paths and call next() for API routes (as shown above) 3. Be moved to run AFTER all other routes are registered This appears to be a production-mode specific issue since the catch-all is only active when NODE_ENV !== "development" (line 88 in /app/server/index.js). Hope this helps identify and resolve the issue permanently!
yindo changed title from [BUG]: AnythingLLM Embed Widget Not Working to [GH-ISSUE #3978] [BUG]: AnythingLLM Embed Widget Not Working 2026-06-05 14:47:04 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2530