dbxlite-ui 0.3.2 → 0.3.3

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.
Files changed (2) hide show
  1. package/dist/cli.js +21 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -165,16 +165,37 @@ console.log(`Assets directory: ${ASSETS_DIR}`);
165
165
  // index.html so the React router can handle it (mirrors the Vercel rewrite).
166
166
  const ASSET_PREFIXES = ['/assets/', '/duckdb/', '/sql-templates/', '/logo/', '/screenshots/'];
167
167
  const ASSET_FILES = ['/robots.txt', '/sitemap.xml', '/favicon.ico'];
168
+ // API prefixes never fall back to index.html — they're CORS-proxy paths
169
+ // (Snowflake, BigQuery) that exist in the Vercel deployment but not here.
170
+ // Returning index.html for these breaks the connector with "Unexpected
171
+ // token '<'" when it tries to JSON.parse the HTML response.
172
+ const API_PREFIXES = ['/api/'];
168
173
 
169
174
  function isAssetPath(urlPath) {
170
175
  return ASSET_PREFIXES.some(p => urlPath.startsWith(p)) || ASSET_FILES.includes(urlPath);
171
176
  }
172
177
 
178
+ function isApiPath(urlPath) {
179
+ return API_PREFIXES.some(p => urlPath.startsWith(p));
180
+ }
181
+
173
182
  // Create asset server
174
183
  const server = createServer((req, res) => {
175
184
  let urlPath = req.url.split('?')[0];
176
185
  if (urlPath === '/') urlPath = '/index.html';
177
186
 
187
+ // Cloud API proxy paths (Snowflake / BigQuery CORS proxies) only exist in
188
+ // the Vercel deployment. Locally we 501 with a JSON body so the connector
189
+ // can show a clear error instead of choking on HTML.
190
+ if (isApiPath(urlPath)) {
191
+ res.writeHead(501, { 'Content-Type': 'application/json' });
192
+ res.end(JSON.stringify({
193
+ error: 'cloud_proxy_unavailable',
194
+ message: `${urlPath} requires the dbxlite-cloud proxy. Use sql.dbxlite.com for Snowflake/BigQuery, or run dbxlite locally only for DuckDB.`,
195
+ }));
196
+ return;
197
+ }
198
+
178
199
  let filePath = join(ASSETS_DIR, urlPath);
179
200
 
180
201
  // Security: prevent directory traversal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbxlite-ui",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Local UI for DuckDB - replaces duckdb -ui with dbxlite",
5
5
  "homepage": "https://github.com/hfmsio/dbxlite",
6
6
  "bugs": "https://github.com/hfmsio/dbxlite/issues",