fix: add Tailwind CSS, Unsplash, and popular CDNs to asset proxy allowlist - #186
Merged
Merged
Conversation
…llowlist Stitch-generated screens frequently reference external CDNs like cdn.tailwindcss.com and images.unsplash.com, but the AssetGateway security allowlist only permitted Google-owned domains and cdnjs.cloudflare.com. This caused the /_stitch/asset proxy to return 404 for these resources, breaking Tailwind CSS rendering entirely (ReferenceError: tailwind is not defined) and failing to load images. Added: - cdn.tailwindcss.com (Tailwind CSS CDN) - images.unsplash.com (Unsplash stock images) - cdn.jsdelivr.net (jsDelivr CDN) - unpkg.com (unpkg CDN) Also added 10 validateAssetUrl tests covering all allowed and rejected domain patterns.
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.
Problem
The
/_stitch/assetproxy returns 404 for Tailwind CSS and Unsplash images, breaking visual rendering of Stitch-generated screens.When the local serve command (
stitch-mcp serve -p <id> --json) hosts screens, theAssetGatewayrewrites external URLs like:into proxied form:
But
AssetGateway.validateAssetUrl()rejectscdn.tailwindcss.combecause it is not in theALLOWED_HOST_PATTERNSallowlist — causing the proxy to return null and the middleware to respond with 404.User-visible symptoms:
ReferenceError: tailwind is not defined— the Tailwind config block runs before the CDN script loadsRoot Cause
ALLOWED_HOST_PATTERNSonly contained Google-owned domains (googleapis.com,gstatic.com,googleusercontent.com) andcdnjs.cloudflare.com. Stitch generation model frequently emits Tailwind CSS CDN references and Unsplash image URLs, neither of which were in the allowlist.Fix
Added 4 commonly-used CDN domains to the allowlist:
cdn.tailwindcss.comimages.unsplash.comcdn.jsdelivr.netunpkg.comTesting
Added 10 new
validateAssetUrltests covering: