Skip to content

fix(import): read VITE_CORS_PROXY from a Secret too; bypass YouTube consent gate - #137

Merged
itabajah merged 1 commit into
mainfrom
fix/cors-proxy-secret-and-youtube
Jul 7, 2026
Merged

fix(import): read VITE_CORS_PROXY from a Secret too; bypass YouTube consent gate#137
itabajah merged 1 commit into
mainfrom
fix/cors-proxy-secret-and-youtube

Conversation

@itabajah

@itabajah itabajah commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Two fixes found while testing the deployed worker on the live site.

1. The live site wasn't using the worker (the main fix)

The worker was deployed and VITE_CORS_PROXY was set — but as a repository Secret, while the deploy workflow only read it as a Variable (${{ vars.VITE_CORS_PROXY }}). So vars. was empty, the build baked in nothing, and the site kept falling back to the public proxy.cors.sh.

Fix: read it from either place —

VITE_CORS_PROXY: ${{ vars.VITE_CORS_PROXY || secrets.VITE_CORS_PROXY }}

Robust and future-proof; no matter which tab it's set in, the build picks it up.

2. YouTube consent gate broke recording imports

In the EU/UK, YouTube 3xx-redirects the playlist fetch to its "before you continue" consent interstitial (consent.youtube.com/m…), which has no CORS header — so the import failed. Fix: send a consent cookie (SOCS=CAI; CONSENT=YES+…) for youtube.com/youtu.be requests in both the Cloudflare Worker and the Vite dev proxy, so the playlist page loads directly. Verified the cookie keeps ytInitialData and watch links intact (it only affects EU/UK regions; harmless elsewhere). This is a server-side-only fix, so it needs the worker (public proxies can't attach the cookie).

Verification

Local gates green: typecheck, lint (0 warnings), format, importer tests (186), worker syntax-checked.

After merge

Re-run Deploy to GitHub Pages — the build will then bake in your VITE_CORS_PROXY (from the Secret) and the site will use your worker: Cheesefork fast, YouTube working.

🤖 Generated with Claude Code

…onsent gate

Two follow-ups from live testing of the worker:

1. The worker was deployed and VITE_CORS_PROXY was set, but as a repo *Secret*
   while deploy.yml only read `vars.VITE_CORS_PROXY` — so the build baked in
   nothing and the live site kept falling back to the public proxy. Read it from
   either place: `${{ vars.VITE_CORS_PROXY || secrets.VITE_CORS_PROXY }}`.

2. YouTube's EU/UK "before you continue" consent page (consent.youtube.com/m…)
   3xx-redirected the fetch away from the playlist, breaking recording imports.
   Send a consent cookie (SOCS=CAI; CONSENT=YES+…) for youtube.com/youtu.be in
   both the worker and the Vite dev proxy so the playlist page loads directly.
   Verified the cookie keeps ytInitialData + watch links intact.

Docs (worker README) updated: VITE_CORS_PROXY may be a Variable or a Secret.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@itabajah
itabajah merged commit d7e179b into main Jul 7, 2026
2 checks passed
@itabajah
itabajah deleted the fix/cors-proxy-secret-and-youtube branch July 7, 2026 09:34
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.

1 participant