Skip to content

Commit a60a332

Browse files
authored
Use custom backend URL even if dev token is present (#4212)
* allow custom backend URL in dev envs * add changeset
1 parent d5bc467 commit a60a332

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.changeset/better-stamps-fall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@roo-code/types": patch
3+
---
4+
5+
Fix to respect KILOCODE_BACKEND_BASE_URL when dev tokens are present

packages/types/src/kilocode/kilocode.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,16 @@ export function getKiloBaseUriFromToken(kilocodeToken?: string) {
5757
typeof atob !== "undefined" ? atob(payload_string) : Buffer.from(payload_string, "base64").toString()
5858
const payload = JSON.parse(payload_json)
5959
//note: this is UNTRUSTED, so we need to make sure we're OK with this being manipulated by an attacker; e.g. we should not read uri's from the JWT directly.
60-
if (payload.env === "development") return "http://localhost:3000"
60+
// For dev tokens, check if KILOCODE_BACKEND_BASE_URL is set to a custom value
61+
if (payload.env === "development") {
62+
const baseUrl = getGlobalKilocodeBackendUrl()
63+
// This allows pointing to custom dev backends beyond just those accessible on localhost
64+
// (e.g., 192.168.x.x, staging servers)
65+
if (baseUrl !== DEFAULT_KILOCODE_BACKEND_URL) {
66+
return baseUrl
67+
}
68+
return "http://localhost:3000"
69+
}
6170
} catch (_error) {
6271
console.warn("Failed to get base URL from Kilo Code token")
6372
}

0 commit comments

Comments
 (0)