Third-Party External CDN Dependency
Error:
[ERR_EXTERNAL_CDN] Found external CDN reference. Code the framework ships to visitors must not load third-party CDNs. Self-host or use @stnd/fonts / @stnd/icon.
Scope: whose choice is it?
The rule is about the code the framework ships to a visitor — a layout, a module, a component. For that code, we pick how things are delivered, and self-hosting is strictly better.
It does not forbid what a person chooses to put on their own page, nor a tool that fetches something only because you asked:
| Case | Allowed? | Why |
|---|---|---|
| A module or layout that loads GSAP, KaTeX, Prism… from jsDelivr / cdnjs | No — this is the error | We choose the delivery; bundle the npm package instead. |
An author’s note that loads a Google Font (styles: frontmatter, an @import in its CSS) |
Yes | The file is the author’s. The CSP allows the font hosts so it works; the reader’s browser contacts Google, which the author accepted. |
| The Workshop previewing a Google Font you typed | Yes | A design tool, on request; it previews and never publishes. |
The Problem
A component references an external third-party CDN (such as cdn.jsdelivr.net, unpkg.com, cdnjs.cloudflare.com, or fonts.googleapis.com) via a <script> or <link> tag.
<!-- Problematic: External third-party CDN -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
<script src="https://unpkg.com/lodash@4.17.21/lodash.min.js"></script>
The Why
Standard applications are designed for maximum privacy, sovereign hosting, deterministic builds, and offline resilience:
- Zero tracking & GDPR compliance: Loading external Google Fonts or CDN scripts leaks user IP addresses to third-party providers without user consent.
- Reliability & Security: Third-party CDNs can suffer outages, latency spikes, or supply-chain poisoning attacks.
- Local and Edge First: Standard packages like
@stnd/fontsand@stnd/iconbundle assets locally with immutable edge cache headers (_headers), eliminating external network requests completely.
The Solution
Self-host the dependency or install the corresponding @stnd/* package:
1. Fonts $\longrightarrow$ @stnd/fonts
Instead of Google Fonts, use @stnd/fonts which self-hosts Swiss typography with variable font weights:
<!-- Compliant -->
<link rel="stylesheet" href="/fonts/inter.css">
2. Icons $\longrightarrow$ @stnd/icon
Instead of CDN icon sets (FontAwesome, Material Icons), use @stnd/icon:
---
import Icon from "@stnd/icon/Icon.astro";
---
<Icon name="search" />
3. Vendor Libraries $\longrightarrow$ npm dependency
Install the package locally with pnpm and import it through Vite:
pnpm add katex
import katex from "katex";
import "katex/dist/katex.min.css";