Skip to content

Commit 01d97da

Browse files
committed
verboser comment
1 parent 07eee10 commit 01d97da

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

chat/src/components/chat-provider.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,16 @@ export function ChatProvider({ children }: PropsWithChildren) {
5757
const [serverStatus, setServerStatus] = useState<ServerStatus>("unknown");
5858
const eventSourceRef = useRef<EventSource | null>(null);
5959
const searchParams = useSearchParams();
60-
// NOTE(cian): When hosting this application on a subpath, we need to
61-
// ensure that the agent API URL is correctly set. Refer to
62-
// https://github.com/coder/coder/issues/18779#issuecomment-3133290494
60+
// NOTE(cian): We use '../../' here to construct the agent API URL relative
61+
// to the current window location. Let's say the app is hosted on a subpath
62+
// `/@admin/workspace.agent/apps/ccw/`. When you visit this URL you get
63+
// redirected to `/@admin/workspace.agent/apps/ccw/chat/embed`. This serves
64+
// this React application, but it needs to know where the agent API is hosted.
65+
// This will be at the root of where the application is mounted e.g.
66+
// `/@admin/workspace.agent/apps/ccw/`. Previously we used
67+
// `window.location.origin` but this assumes that the application owns the
68+
// entire origin.
69+
// See: https://github.com/coder/coder/issues/18779#issuecomment-3133290494 for more context.
6370
const defaultAgentAPIURL = new URL("../../", window.location.href).toString();
6471
const agentAPIUrl = searchParams.get("url") || defaultAgentAPIURL;
6572

0 commit comments

Comments
 (0)