Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: default scheme-less public provider URLs to https (follow-up to #14594) (#14629)

Michael Hancd81b0368adb
diff --git a/studio/frontend/src/features/chat/provider-base-url.ts b/studio/frontend/src/features/chat/provider-base-url.ts
index aa21eb6b9bc..c21b5ebd719 100644
--- a/studio/frontend/src/features/chat/provider-base-url.ts
+++ b/studio/frontend/src/features/chat/provider-base-url.ts
@@ -5,6 +5,14 @@ const SCHEMELESS_HOST = /^(\[[0-9a-f:.]+\]|[a-z0-9.-]+)(:\d+)?([/?#].*)?$/i;
// Pasted full endpoints: the client appends these itself, so keeping one requests /chat/completions/models.
const ENDPOINT_SUFFIX =
/\/(chat\/completions|completions|responses|messages|models)\/*$/i;
+const LOCAL_HOST_NAME =
+ /^(\[.*\]|\d{1,3}(\.\d{1,3}){3}|[^.]+|.+\.(localhost|local|lan|internal|home\.arpa))$/i;
+
+// The API key rides on every request, so a bare public domain (api.openai.com/v1) must not default to cleartext.
+function defaultScheme(host: string, port: string | undefined): string {
+ if (port && port !== ":443") return "http";
+ return LOCAL_HOST_NAME.test(host) ? "http" : "https";
+}
export function normalizeProviderBaseUrl(
input: string,
@@ -12,8 +20,11 @@ export function normalizeProviderBaseUrl(
): string | null {
let trimmed = input.trim();
if (!trimmed) return null;
- if (!trimmed.includes("://") && SCHEMELESS_HOST.test(trimmed)) {
- trimmed = `http://${trimmed}`;
+ const schemeless = trimmed.includes("://")
+ ? null
+ : SCHEMELESS_HOST.exec(trimmed);
+ if (schemeless) {
+ trimmed = `${defaultScheme(schemeless[1], schemeless[2])}://${trimmed}`;
}
let parsed: URL;
try {
diff --git a/studio/frontend/tests/provider-base-url-normalize.test.ts b/studio/frontend/tests/provider-base-url-normalize.test.ts
index cbf9113dc3a..4a4647e6660 100644
--- a/studio/frontend/tests/provider-base-url-normalize.test.ts
+++ b/studio/frontend/tests/provider-base-url-normalize.test.ts
@@ -27,6 +27,24 @@ test("a host without a scheme is read as http", () => {
);
});
+test("a public domain without a scheme is read as https", () => {
+ assert.equal(
+ normalizeProviderBaseUrl("api.openai.com/v1"),
+ "https://api.openai.com/v1",
+ );
+ assert.equal(
+ normalizeProviderBaseUrl("openrouter.ai:443/api/v1"),
+ "https://openrouter.ai/api/v1",
+ );
+ assert.equal(
+ normalizeProviderBaseUrl("gpu.example.com:8000/v1"),
+ "http://gpu.example.com:8000/v1",
+ );
+ for (const host of ["box.local", "host.docker.internal", "nas.lan"]) {
+ assert.equal(normalizeProviderBaseUrl(`${host}/v1`), `http://${host}/v1`);
+ }
+});
+
test("other schemes still fail", () => {
assert.throws(
() => normalizeProviderBaseUrl("ftp://host/v1"),