Skip to content

Add WASM fetch resolver support#26

Merged
SirajChokshi merged 3 commits into
mainfrom
cursor/wasm-resolvers-support-dfb8
Apr 7, 2026
Merged

Add WASM fetch resolver support#26
SirajChokshi merged 3 commits into
mainfrom
cursor/wasm-resolvers-support-dfb8

Conversation

@SirajChokshi
Copy link
Copy Markdown
Owner

Summary

  • inject a runtime fetch resolver into processed preview HTML so repo-host asset fetches are proxied through CodeTabs
  • encode proxied request URLs to safely support nested query strings and special characters
  • add unit tests for HTML processing to cover resolver injection and root-path rewriting

Testing

  • npm run test
  • npm run lint
  • npm run check
Open in Web Open in Cursor 

Co-authored-by: Siraj Chokshi <SirajChokshi@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
static-preview Ready Ready Preview, Comment Apr 6, 2026 11:26pm

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Proxy URL duplicated across two source files
    • Extracted the proxy base URL into a shared PROXY_BASE_URL constant in fetch.ts and imported it in html.ts, eliminating the duplication.

Create PR

Or push these changes by commenting:

@cursor push 24fe783b8b
Preview (24fe783b8b)
diff --git a/src/utils/fetch.ts b/src/utils/fetch.ts
--- a/src/utils/fetch.ts
+++ b/src/utils/fetch.ts
@@ -1,8 +1,10 @@
 import { PreviewError, errorType } from './errors'
 
+export const PROXY_BASE_URL = 'https://api.codetabs.com/v1/proxy/?quest='
+
 export async function proxyFetch(url: string) {
   const res = await fetch(
-    `https://api.codetabs.com/v1/proxy/?quest=${encodeURIComponent(url)}`,
+    `${PROXY_BASE_URL}${encodeURIComponent(url)}`,
     undefined,
   )
 

diff --git a/src/utils/lang/html.ts b/src/utils/lang/html.ts
--- a/src/utils/lang/html.ts
+++ b/src/utils/lang/html.ts
@@ -1,3 +1,5 @@
+import { PROXY_BASE_URL } from '../fetch'
+
 export function isHTML(maybeHTML: string): boolean {
   const $div = document.createElement('div')
   $div.innerHTML = maybeHTML
@@ -7,7 +9,7 @@
 function getFetchResolverScript() {
   return `<script data-static-preview-fetch-resolver>
 ;(() => {
-  const proxyPrefix = 'https://api.codetabs.com/v1/proxy/?quest='
+  const proxyPrefix = '${PROXY_BASE_URL}'
   const nativeFetch = window.fetch.bind(window)
 
   const shouldProxy = (url) => {

You can send follow-ups to the cloud agent here.

Comment thread src/utils/lang/html.ts
function getFetchResolverScript() {
return `<script data-static-preview-fetch-resolver>
;(() => {
const proxyPrefix = 'https://api.codetabs.com/v1/proxy/?quest='
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxy URL duplicated across two source files

Low Severity

The proxy base URL https://api.codetabs.com/v1/proxy/?quest= is hardcoded independently in both fetch.ts and in the injected script string inside html.ts. If the proxy endpoint ever changes, one location could easily be updated while the other is missed, causing silent breakage in either server-side fetching or client-side WASM fetch proxying. A shared constant interpolated into both call sites would eliminate this risk.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3286ee7. Configure here.

Co-authored-by: Siraj Chokshi <SirajChokshi@users.noreply.github.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Logger refactor creates unused dead variable
    • Resolved the factory function once before calling createLogger, eliminating the dead allocation of a second unused logger instance.

Create PR

Or push these changes by commenting:

@cursor push 8c51329317
Preview (8c51329317)
diff --git a/src/utils/logger.ts b/src/utils/logger.ts
--- a/src/utils/logger.ts
+++ b/src/utils/logger.ts
@@ -47,14 +47,9 @@
   }
 }
 
-const logger = createLogger(logbench)
-
-// Keep existing styling behavior for compatible environments.
-const styledLogger = createLogger((logbench as { default?: unknown }).default)
-
-const resolvedLogger =
+const factory =
   typeof (logbench as { default?: unknown }).default === 'function'
-    ? styledLogger
-    : logger
+    ? (logbench as { default: unknown }).default
+    : logbench
 
-export default resolvedLogger
+export default createLogger(factory)

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit c6ab352. Configure here.

Comment thread src/utils/logger.ts Outdated
@SirajChokshi SirajChokshi marked this pull request as ready for review April 6, 2026 22:53
Co-authored-by: Siraj Chokshi <SirajChokshi@users.noreply.github.com>
@SirajChokshi SirajChokshi merged commit 5679baf into main Apr 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants