fix(daemon): add Access-Control-Allow-Private-Network for Chrome PNA#197
Conversation
Chrome's Private Network Access (PNA) requires this header on CORS preflights from public origins (HTTPS pages) to private IPs (127.0.0.1). Without it the preflight fails silently and the real POST is never sent — making the dashboard 'Sync Now' button look like a no-op.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary
WalkthroughThe CORS preflight handler in the daemon's HTTP server now declares support for Private Network Access by adding the ChangesPrivate Network Access CORS Header
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested labels
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.20.0)OpenGrep fatal error (exit code 2): �[32m✔�[39m �[1mOpengrep OSS�[0m �[1m Loading rules from local config...�[0m Comment |
Bug: dashboard Sync Now button silently failed in Chrome/Edge because the daemon CORS preflight did not include Access-Control-Allow-Private-Network. Chrome PNA blocks requests from https:// public origins to private IPs (127.0.0.1) unless this header is on the preflight. The fetch fails with 'TypeError: Failed to fetch' before the real POST is sent.
Fix: add the header to do_OPTIONS in daemon.py.
Verify:
curl -X OPTIONS http://127.0.0.1:8765/sync -H 'Origin: https://app.gradata.ai' -H 'Access-Control-Request-Private-Network: true' -i
Response now includes: Access-Control-Allow-Private-Network: true
Follow-up to #196.