From 7838e8ad3968925fc2592dde487c1264d59d5aba Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 10 Apr 2026 13:36:35 +0000 Subject: [PATCH] Use actual origin in API key usage examples The examples on /api-keys were hardcoded to localhost:8888 which is wrong for remote users. Use window.location.origin so the examples show the correct URL regardless of where the user is connecting from. --- studio/frontend/src/features/auth/api-keys-page.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/studio/frontend/src/features/auth/api-keys-page.tsx b/studio/frontend/src/features/auth/api-keys-page.tsx index 806ec99ccf..5f76a91759 100644 --- a/studio/frontend/src/features/auth/api-keys-page.tsx +++ b/studio/frontend/src/features/auth/api-keys-page.tsx @@ -280,7 +280,9 @@ function KeysTable({ } function UsageExamples() { - const curlExample = `curl http://localhost:8888/v1/chat/completions \\ + const base = window.location.origin; + + const curlExample = `curl ${base}/v1/chat/completions \\ -H "Authorization: Bearer sk-unsloth-YOUR_KEY" \\ -H "Content-Type: application/json" \\ -d '{ @@ -291,7 +293,7 @@ function UsageExamples() { const pythonExample = `from openai import OpenAI client = OpenAI( - base_url="http://localhost:8888/v1", + base_url="${base}/v1", api_key="sk-unsloth-YOUR_KEY", ) @@ -303,7 +305,7 @@ response = client.chat.completions.create( for chunk in response: print(chunk.choices[0].delta.content or "", end="")`; - const toolsExample = `curl http://localhost:8888/v1/chat/completions \\ + const toolsExample = `curl ${base}/v1/chat/completions \\ -H "Authorization: Bearer sk-unsloth-YOUR_KEY" \\ -H "Content-Type: application/json" \\ -d '{