@assemble-inc/chat-widget 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -5
- package/dist/embed.iife.js +379 -0
- package/dist/index.js +2256 -2232
- package/dist/server.cjs +65 -18
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +65 -18
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -48,14 +48,13 @@ The widget renders as a fixed floating button in the bottom-right corner (config
|
|
|
48
48
|
|
|
49
49
|
### 2. Add the server-side handler
|
|
50
50
|
|
|
51
|
+
The simplest setup is to mount the handler **on your existing app server** so that the widget's default `endpoint: '/api/chat'` resolves correctly:
|
|
52
|
+
|
|
51
53
|
```ts
|
|
52
|
-
// server
|
|
53
|
-
import express from "express";
|
|
54
|
+
// your existing Express/Next/etc. server
|
|
54
55
|
import { createChatHandler } from "@assemble-inc/chat-widget/server";
|
|
55
56
|
|
|
56
|
-
const app = express();
|
|
57
57
|
app.use(express.json());
|
|
58
|
-
|
|
59
58
|
app.post(
|
|
60
59
|
"/api/chat",
|
|
61
60
|
createChatHandler({
|
|
@@ -64,8 +63,24 @@ app.post(
|
|
|
64
63
|
mcpBearerToken: process.env.MCP_BEARER_TOKEN,
|
|
65
64
|
}),
|
|
66
65
|
);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If you prefer to run a **separate API server** (e.g. on port 3006), you must tell the widget where to find it — otherwise it will POST to your frontend server and get a 404:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
// Pass the full URL when the API server is on a different port
|
|
72
|
+
<Widget config={{ endpoint: "http://localhost:3006/api/chat" }} />
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Or proxy `/api` to the API server in your frontend dev config (Vite example):
|
|
67
76
|
|
|
68
|
-
|
|
77
|
+
```ts
|
|
78
|
+
// vite.config.ts
|
|
79
|
+
server: {
|
|
80
|
+
proxy: {
|
|
81
|
+
"/api": "http://localhost:3006",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
69
84
|
```
|
|
70
85
|
|
|
71
86
|
### 3. Environment variables
|