Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 10 additions & 27 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ debugLog('Express app and HTTP server created');
// 3. Allows localhost ports in development for local dev convenience.
// 4. Falls back to the FRONTEND_URL env var when set (useful in staging).
// ---------------------------------------------------------------------------
const CAT_HERDING_ORIGIN_RE =
/^https:\/\/([\w-]+\.)?cat-herding\.net(:\d+)?$/;
const CAT_HERDING_ORIGIN_RE = /^https:\/\/([\w-]+\.)?cat-herding\.net(:\d+)?$/;

const DEV_LOCALHOST_ORIGINS = new Set([
'http://localhost:5173',
Expand All @@ -114,12 +113,21 @@ const DEV_LOCALHOST_ORIGINS = new Set([
]);

function isAllowedOrigin(origin: string | undefined): boolean {
if (!origin) return true; // server-to-server / curl — no Origin header
if (CAT_HERDING_ORIGIN_RE.test(origin)) return true;
if (process.env.NODE_ENV !== 'production' && DEV_LOCALHOST_ORIGINS.has(origin))
if (!origin) {
return true; // server-to-server / curl — no Origin header
}
if (CAT_HERDING_ORIGIN_RE.test(origin)) {
return true;
if (process.env.FRONTEND_URL && origin === process.env.FRONTEND_URL)
}
if (
process.env.NODE_ENV !== 'production' &&
DEV_LOCALHOST_ORIGINS.has(origin)
) {
return true;
}
if (process.env.FRONTEND_URL && origin === process.env.FRONTEND_URL) {
return true;
}
return false;
}

Expand Down
2 changes: 0 additions & 2 deletions embed/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export class ChatWidget {
private statusEl!: HTMLDivElement;
/** Optional sign-in upgrade banner shown to unauthed users. */
private signInEl: HTMLDivElement | null = null;
private inputRowEl: HTMLFormElement | null = null;
private typingEl: HTMLDivElement | null = null;
private socket: Socket | null = null;
private conversationId: string | null = null;
Expand Down Expand Up @@ -263,7 +262,6 @@ export class ChatWidget {
e.preventDefault();
this.handleSend();
});
this.inputRowEl = inputRow;
panel.appendChild(inputRow);

if (this.opts.footerHtml) {
Expand Down
Loading
Loading