File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments