zero-doc 1.0.14 → 1.0.15

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.
@@ -147,9 +147,9 @@ class AIAnalyzer {
147
147
  if (!this.apiUrl) {
148
148
  throw new Error('Proxy API URL not configured');
149
149
  }
150
- const url = this.apiUrl.trim();
151
- if (!url.startsWith('http://') && !url.startsWith('https://')) {
152
- throw new Error(`Invalid API URL: "${url}". URL must start with http:// or https://`);
150
+ const baseUrl = this.apiUrl.trim();
151
+ if (!baseUrl.startsWith('http://') && !baseUrl.startsWith('https://')) {
152
+ throw new Error(`Invalid API URL: "${baseUrl}". URL must start with http:// or https://`);
153
153
  }
154
154
  try {
155
155
  const headers = {
@@ -159,7 +159,23 @@ class AIAnalyzer {
159
159
  if (this.token) {
160
160
  headers['Authorization'] = `Bearer ${this.token}`;
161
161
  }
162
- const response = await fetch(url, {
162
+ // First, get the actual URL to use for the prompt request
163
+ const urlEndpoint = `${baseUrl}/url`;
164
+ const urlResponse = await fetch(urlEndpoint, {
165
+ method: 'GET',
166
+ headers,
167
+ });
168
+ if (!urlResponse.ok) {
169
+ const errorText = await urlResponse.text().catch(() => 'No error details');
170
+ throw new Error(`Failed to get API URL (${urlResponse.status}): ${urlResponse.statusText}. ${errorText}`);
171
+ }
172
+ const urlData = await urlResponse.json();
173
+ const actualUrl = urlData.url || urlData.endpoint || urlData.apiUrl;
174
+ if (!actualUrl || (typeof actualUrl !== 'string')) {
175
+ throw new Error('Invalid response from /url endpoint: missing or invalid URL');
176
+ }
177
+ // Now make the actual prompt request to the URL we got
178
+ const response = await fetch(actualUrl, {
163
179
  method: 'POST',
164
180
  headers,
165
181
  body: JSON.stringify({ prompt }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zero-doc",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Zero-Config API Documentation Generator - Generate beautiful API docs from your code automatically",
5
5
  "main": "dist/index.js",
6
6
  "bin": {