feat: Cloudflare Worker proxy for Microsoft API + Back button fix + favicon #7
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: shekhar/windows-iso-downloader#7
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/cf-worker-proxy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Changes
fix: Back button navigates to external referrer (#5)
When users land directly on a product URL from an external source, the
Back button now always returns to the home page instead of the external
referrer. Uses
window.history.state?.idxto detect whether priorin-app history exists before calling
navigate(-1).feat: Cloudflare Worker proxy to avoid Microsoft IP blocks (#6)
The Go backend now routes all Microsoft API calls through a Cloudflare
Worker (
cloudflare-worker/worker.js) whenCF_WORKER_URLis set.Cloudflare's distributed edge IPs prevent any single IP from accumulating
enough request volume to trigger Microsoft's block (error 715-123130).
The Worker is protected by a shared secret (
CF_WORKER_SECRET) so onlythe backend can use it. Self-hosters can omit both env vars to keep the
existing direct-to-Microsoft behaviour.
Required env vars on the backend:
CF_WORKER_URL— your deployed Worker URLCF_WORKER_SECRET— must match the secret set in the Worker's settingsfix: Add favicon
Closes #5, Closes #6
Summary by CodeRabbit
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
4c70f498-232c-4963-9994-e618225d8165📥 Commits
Reviewing files that changed from the base of the PR and between
a8f9ba1da1and8b036e94ba.⛔ Files ignored due to path filters (1)
frontend/public/favicon.icois excluded by!**/*.ico📒 Files selected for processing (3)
backend/main.gocloudflare-worker/worker.jsfrontend/src/pages/ProductDetailPage.tsx📝 Walkthrough
Walkthrough
PR adds Cloudflare Worker proxy routing for Microsoft API calls to distribute outbound traffic across edge IPs instead of a single server IP, preventing rate-limiting blocks. Backend imports
os, defines proxy helpers (setWorkerSecret,proxyURL), and applies them to setupSession, /skuinfo, and /proxy handlers. New Cloudflare Worker validates secret headers and forwards allowed hosts. Frontend back button now falls back to home when no in-app history exists.Changes
Cloudflare Worker Proxy Infrastructure
backend/main.goosimport, readsCF_WORKER_SECRET, and definessetWorkerSecretfunction to conditionally setX-Worker-Secretheader andproxyURLfunction to rewrite Microsoft URLs throughCF_WORKER_URLwith original hostname ashostquery parameter.backend/main.goproxyURLfor URL construction and applysetWorkerSecretto each request.backend/main.goproxyURLand applysetWorkerSecretto outbound requests.backend/main.goproxyURLand applysetWorkerSecret.cloudflare-worker/worker.jsX-Worker-Secretheader, enforces allowlisted upstream hosts, rewrites URLs to remove host parameter, forwards method and headers, and returns response with CORS headers and Content-Type fallback.Frontend Navigation Fix
frontend/src/pages/ProductDetailPage.tsxwindow.history.state?.idxis present, otherwise falls back to navigating to/instead of always usingnavigate(-1).Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
feat/cf-worker-proxyComment
@coderabbitai helpto get the list of available commands and usage tips.