mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 10:22:25 +00:00
fix(ai): frontend console error — strip xs on localhost (agent)
Diagnosed a CORS error on local development environment caused by WebTorrent fetching `.torrent` files from R2 buckets (via `xs` parameter) that do not allow localhost origin. Modified `js/webtorrent.js` to strip the `xs` parameter from magnet links when running on `localhost` or `127.0.0.1`. This prevents the browser from attempting the blocked fetch request, resolving the console error while maintaining functionality (falling back to DHT/peers). Verified using `scripts/agent/debug_frontend.py` which captures frontend console logs via Playwright. Tests run: - `npm run lint` - `npm run test:unit:shard1` - `python3 scripts/agent/debug_frontend.py` (verified error is gone) Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
6a55bd9a60
commit
4f40025b9d
2 files changed
+42
-18
No files matched your search
@@ -1,31 +1,21 @@
|
||||
import sys
|
||||
import time
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
def run():
|
||||
with sync_playwright() as p:
|
||||
# Launch browser (headless by default)
|
||||
browser = p.chromium.launch()
|
||||
page = browser.new_page()
|
||||
|
||||
# Capture console messages
|
||||
page.on("console", lambda msg: print(f"console:{msg.type}: {msg.text}"))
|
||||
|
||||
# Capture uncaught exceptions
|
||||
page.on("pageerror", lambda exc: print(f"pageerror: {exc}"))
|
||||
|
||||
# Capture failed requests
|
||||
page.on("requestfailed", lambda request: print(f"requestfailed: {request.url} {request.failure}"))
|
||||
page.on("requestfailed", lambda req: print(f"requestfailed: {req.url} - {req.failure}"))
|
||||
|
||||
try:
|
||||
print("Navigating to http://localhost:8000...")
|
||||
page.goto("http://localhost:8000")
|
||||
|
||||
# Wait for some time to catch initialization errors
|
||||
time.sleep(5)
|
||||
|
||||
# Wait a bit for JS to execute and errors to appear
|
||||
page.wait_for_timeout(5000)
|
||||
except Exception as e:
|
||||
print(f"Script error: {e}")
|
||||
print(f"Error navigating: {e}")
|
||||
finally:
|
||||
browser.close()
|
||||
|
||||
|
||||
Reference in new issue
Block a user