Copilot commented on code in PR #812:
URL:
https://github.com/apache/rocketmq-dashboard/pull/812#discussion_r3702296455
##########
web/src/api/ai.ts:
##########
@@ -135,7 +136,7 @@ export async function chatStream(
onChunk: (text: string) => void,
signal?: AbortSignal,
) {
- const response = await fetch('/api/ai/chat', {
+ const response = await fetch(`${API_BASE_URL}/ai/chat`, {
Review Comment:
`${API_BASE_URL}/ai/chat` can produce a double-slash (e.g.
`/studio-api//ai/chat`) if `API_BASE_URL` is configured with a trailing `/`.
This can break routing for some proxies/servers. Consider normalizing the join
(trim trailing `/` from `API_BASE_URL` and ensure the path starts with a single
`/`), or use a small URL-join helper so the result is always exactly one slash
between segments.
##########
web/src/api/ai.test.ts:
##########
@@ -28,6 +28,8 @@ import {
type McpTool,
} from './ai';
+vi.mock('../config', () => ({ API_BASE_URL: '/studio-api' }));
Review Comment:
The module under test (`./ai`) imports `../config` at module evaluation
time. Declaring `vi.mock('../config', ...)` after importing `./ai` relies on
Vitest’s mock-hoisting behavior and can be brittle across module
systems/settings. To make the test ordering unambiguous, move the
`vi.mock('../config', ...)` above the `./ai` import, or switch to dynamically
importing `./ai` after the mock is set up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]