A public chat endpoint needs a rule for widgets whose publisher has not specified an allowed website. The Docker edition of AnythingLLM can require an allowlist so chat widgets with no allowed domains reject requests instead of answering every origin.
The server checks whether EMBED_REQUIRE_ALLOWLIST exists, so even a value of false enables the requirement. Each widget's configured origins still determine which websites may send messages, but an origin header can be forged by a non-browser client; an allowlist does not authenticate visitors or make private workspace content safe to publish.
The requirement covers existing and new widgets on the whole instance. A Linux Docker installation with a mounted environment file is assumed, along with a working chat widget whose Restrict requests from domains list is empty; a widget that already has an allowlist cannot demonstrate the change from unrestricted access to refusal.
Steps to require an allowlist for AnythingLLM chat widgets:
- Open the mounted AnythingLLM environment file in nano.
$ sudo nano "$HOME/anythingllm/.env"
The Docker installation uses this host file for /app/server/.env. A different storage directory has its own .env path. Existing provider credentials and encryption keys must remain unchanged; the file must stay private and readable by the container's UID 1000.
- Add the allowlist requirement at the end of the environment file.
After the restart, every widget without an allowed-domain list will stop answering visitors. Widgets with an existing allowlist keep their current restrictions.
EMBED_REQUIRE_ALLOWLIST="true"
If this variable already has a line, that line enables enforcement regardless of its value; a duplicate is unnecessary. Removing the line and restarting restores the default behavior for empty lists, allowing requests from any origin again.
- Save the environment file in nano.
Ctrl+O followed by Enter writes to the existing filename, preserving its owner and permissions.
- Exit nano with Ctrl+X.
- Restart the AnythingLLM container to load the requirement.
The restart interrupts active chats and makes the instance unavailable to every user until startup finishes.
$ docker restart --timeout 30 anythingllm
The container name is anythingllm in the Docker installation above. This restart reads the mounted file; adding a Docker -e option would instead require recreating the container.
- Set
EMBED_IDto the empty-list widget'sdata-embed-idvalue from its existing script tag.$ EMBED_ID='your-widget-embed-id'
The embed ID is a public widget identifier, not a developer API key. It must identify an enabled widget that answered messages before the change and still has no allowed domains.
- Confirm that the empty-list widget returns HTTP 401 with an
Invalid request.error.$ curl -sS -i \ -H 'Origin: https://help.example.net' \ -H 'Content-Type: application/json' \ --data '{"sessionId":"11111111-1111-4111-8111-111111111111","message":"Hello"}' \ "http://localhost:3001/api/embed/$EMBED_ID/stream-chat"The URL addresses AnythingLLM on the Docker host; a remote host needs its reachable address instead of localhost. The sample Origin represents a website making the request, and the fixed session ID is a disposable test conversation. Enforcement returns 401 Unauthorized with "type":"abort" and "error":"Invalid request.". A 200 chat stream means the empty-list widget is still answering; 404 indicates a wrong widget ID, while a connection failure means the server is not ready or the address is wrong.