-
Notifications
You must be signed in to change notification settings - Fork 227
Proxy subroute with injection #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
aidenybai
wants to merge
4
commits into
main
Choose a base branch
from
cursor/proxy-subroute-with-injection-b47e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 Agent can help with this pull request. Just |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@react-grab/cli
grab
@react-grab/ami
@react-grab/amp
@react-grab/claude-code
@react-grab/codex
@react-grab/cursor
@react-grab/droid
@react-grab/gemini
@react-grab/opencode
react-grab
@react-grab/relay
@react-grab/utils
commit: |
- 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a
/proxyroute 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
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.
Written for commit 6280b23. Summary will update on new commits.