Skip to content

Conversation

@aidenybai
Copy link
Owner

@aidenybai aidenybai commented Feb 5, 2026

Add a /proxy route to fetch and inject React Grab into external HTML content.

This allows users to proxy any website by providing its URL as a query parameter (/proxy?url=https://example.com), injecting the React Grab script into the page's head, and rewriting relative URLs to absolute ones for proper asset loading.


Slack Thread

Open in Cursor Open in Web


Summary by cubic

Add a /proxy route that fetches external pages, injects React Grab, and rewrites navigation to stay within the proxy. Adds an asset proxy with CORS and caching, and patches History/fetch/XHR so SPAs and assets work without CORS errors.

  • New Features
    • Accepts url via /proxy?url=..., follows redirects.
    • Validates HTTP/HTTPS and HTML; returns JSON errors.
    • Rewrites //meta-refresh to /proxy; injects (preserves hash/mailto/tel/javascript).
    • Adds /proxy/asset with CORS headers and immutable caching; patches fetch/XHR to proxy asset requests and avoid CORS.
    • Patches History API to proxy SPA navigation and prevent SecurityError; responses send text/html and X-Proxied-From; routes are force-dynamic.

Written for commit 6280b23. Summary will update on new commits.

- Accept URL via query param: /proxy?url=https://example.com
- Fetch target URL server-side
- Inject React Grab script tag into <head>
- Rewrite relative URLs to absolute so assets load from origin
- Return modified HTML with appropriate headers

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Feb 5, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Feb 5, 2026

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

Project Deployment Actions Updated (UTC)
react-grab-website Ready Ready Preview, Comment Feb 5, 2026 7:05am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

@react-grab/cli

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/cli@153

grab

npm i https://pkg.pr.new/aidenybai/react-grab/grab@153

@react-grab/ami

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/ami@153

@react-grab/amp

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/amp@153

@react-grab/claude-code

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/claude-code@153

@react-grab/codex

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/codex@153

@react-grab/cursor

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/cursor@153

@react-grab/droid

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/droid@153

@react-grab/gemini

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/gemini@153

@react-grab/opencode

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/opencode@153

react-grab

npm i https://pkg.pr.new/aidenybai/react-grab@153

@react-grab/relay

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/relay@153

@react-grab/utils

npm i https://pkg.pr.new/aidenybai/react-grab/@react-grab/utils@153

commit: 6280b23

- Rewrite <a> href attributes to go through /proxy
- Rewrite <form> action attributes for form submissions
- Rewrite <meta http-equiv='refresh'> redirect URLs
- Use <base> tag for assets (images, scripts, CSS)
- Preserve hash links, mailto:, tel:, javascript: as-is

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
- Inject script that wraps history.pushState and history.replaceState
- Rewrite URLs to go through proxy before calling native History API
- Prevents 'A history state object with URL cannot be created' errors
- Required for SPAs that use client-side routing

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
- Create /proxy/asset route to proxy assets with CORS headers
- Patch window.fetch to route requests through asset proxy
- Patch XMLHttpRequest.open to route requests through asset proxy
- Fixes CORS errors for JavaScript-loaded images (e.g., Next.js Image)

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
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