fix(media): gate the media API on CDN activation (cdn_enabled)#72
Merged
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
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.
Gate the media API on CDN activation
The miss you caught: the media API (
/api/media/v1/...) didn't check whether CDN/media is activated for the project. So an upload to an un-activated project (cdn_enabled = false) skipped straight to R2 and leaked a rawNotEntitlederror as a 500, instead of a clean, actionable 403.The CDN delivery route already gates on
cdn_enabled(cdn.not_enabled); the media surface should too. Added the same gate toresolveMediaApiContextso it covers all 6 media routes:Evidence
astro-blog.cdn_enabled = false→ media not activated.NotEntitled: Please enable R2 through the Cloudflare Dashboard.cdn.not_enabled(activate CDN in project settings) instead of a 500.Two layers to a working upload (after this)
cdn_enabled = true(the CDN toggle). ← this PR gates on it.NotEntitledis account-level, so staging's R2 isn't enabled yet.typecheck + lint clean; media-api gate test added (6 pass). Companion to #67/#69/#70/#71.