@fudrouter/fsrouter 0.6.114 → 0.6.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -112,7 +112,7 @@ export async function POST_handler(req, res) {
112
112
  normalizedBase = normalizedBase.slice(0, -9);
113
113
  }
114
114
  const modelsUrl = `${normalizedBase}/models`;
115
- const res = await fetchWithTimeout(modelsUrl, {
115
+ const probeRes = await fetchWithTimeout(modelsUrl, {
116
116
  method: "GET",
117
117
  headers: {
118
118
  "x-api-key": apiKey,
@@ -120,11 +120,11 @@ export async function POST_handler(req, res) {
120
120
  "Authorization": `Bearer ${apiKey}`
121
121
  }
122
122
  });
123
- if (res.ok)
124
- return res.json({ valid: true });
123
+ if (probeRes.ok)
124
+ return probeRes.json({ valid: true });
125
125
  // Auth errors - no point trying chat fallback
126
- if (res.status === 401 || res.status === 403) {
127
- return res.json({ valid: false, error: "API key unauthorized" });
126
+ if (probeRes.status === 401 || probeRes.status === 403) {
127
+ return probeRes.json({ valid: false, error: "API key unauthorized" });
128
128
  }
129
129
  // Fallback: try chat/completions if modelId provided
130
130
  if (modelId) {
@@ -143,26 +143,26 @@ export async function POST_handler(req, res) {
143
143
  })
144
144
  });
145
145
  if (chatRes.ok) {
146
- return res.json({ valid: true, method: "chat" });
146
+ return probeRes.json({ valid: true, method: "chat" });
147
147
  }
148
- return res.json({
148
+ return probeRes.json({
149
149
  valid: false,
150
150
  error: getChatErrorMessage(chatRes.status),
151
151
  method: "chat"
152
152
  });
153
153
  }
154
- return res.json({ valid: false, error: getModelsErrorMessage(res.status) });
154
+ return probeRes.json({ valid: false, error: getModelsErrorMessage(probeRes.status) });
155
155
  }
156
156
  // OpenAI Compatible Validation (Default)
157
157
  const modelsUrl = `${baseUrl.replace(/\/$/, "")}/models`;
158
- const res = await fetchWithTimeout(modelsUrl, {
158
+ const probeRes = await fetchWithTimeout(modelsUrl, {
159
159
  headers: { "Authorization": `Bearer ${apiKey}` },
160
160
  });
161
- if (res.ok)
162
- return res.json({ valid: true });
161
+ if (probeRes.ok)
162
+ return probeRes.json({ valid: true });
163
163
  // Auth errors - no point trying chat fallback
164
- if (res.status === 401 || res.status === 403) {
165
- return res.json({ valid: false, error: "API key unauthorized" });
164
+ if (probeRes.status === 401 || probeRes.status === 403) {
165
+ return probeRes.json({ valid: false, error: "API key unauthorized" });
166
166
  }
167
167
  // Fallback: try chat/completions if modelId provided
168
168
  if (modelId) {
@@ -179,7 +179,7 @@ export async function POST_handler(req, res) {
179
179
  })
180
180
  });
181
181
  if (chatRes.ok) {
182
- return res.json({ valid: true, method: "chat" });
182
+ return probeRes.json({ valid: true, method: "chat" });
183
183
  }
184
184
  return res.json({
185
185
  valid: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fudrouter/fsrouter",
3
- "version": "0.6.114",
3
+ "version": "0.6.115",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "9Router v2 — Express Backend (API, SSE, DB, Auth, MITM)",