From b8d2eb9faafeef33340e3d268be4968258af0ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E7=82=8E?= <635735027@qq.com> Date: Fri, 17 Apr 2026 11:34:16 +0800 Subject: [PATCH] fix(generator): use endpoint.url directly in buildRequest to fix URL construction bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation used `new URL(endpoint.url, window.location.origin)` which incorrectly constructed URLs based on the current page's origin. This broke when endpoint URLs were already complete URLs (e.g., http://20.76.57.61:18080/...). The fix uses endpoint.url directly since LLM extraction already provides complete URLs. Also changed from GET with query params to POST with JSON body to match typical API expectations. 🤖 Generated with [Qoder][https://qoder.com] --- src/generated_scene/generator.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/generated_scene/generator.rs b/src/generated_scene/generator.rs index ca2d1a1..0285e97 100644 --- a/src/generated_scene/generator.rs +++ b/src/generated_scene/generator.rs @@ -306,18 +306,12 @@ function validateArgs(args) {{ }} function buildRequest(args, endpoint) {{ - const url = new URL(endpoint.url, window.location.origin); - const params = {{ ...STATIC_PARAMS, ...args }}; - for (const [key, value] of Object.entries(params)) {{ - if (value !== undefined && value !== null) {{ - url.searchParams.set(key, String(value)); - }} - }} - return {{ - url: url.toString(), - method: endpoint.method || 'GET', - headers: {{ 'Content-Type': 'application/json' }} - }}; + // Use endpoint.url directly - it's already a complete URL + const url = endpoint.url; + const method = endpoint.method || 'POST'; + const headers = {{ 'Content-Type': 'application/json' }}; + const body = JSON.stringify({{ ...STATIC_PARAMS, ...args }}); + return {{ url, method, headers, body }}; }} function normalizeRows(rawData) {{ @@ -360,7 +354,8 @@ const defaultDeps = {{ const request = buildRequest(args, endpoint); const response = await fetch(request.url, {{ method: request.method, - headers: request.headers + headers: request.headers, + body: request.body }}); if (!response.ok) throw new Error(`HTTP ${{response.status}}: ${{response.statusText}}`); return response.json();