diff --git a/packages/astro-md/middleware.ts b/packages/astro-md/middleware.ts index 9d47069..02a6b04 100644 --- a/packages/astro-md/middleware.ts +++ b/packages/astro-md/middleware.ts @@ -74,6 +74,11 @@ class SyntaxHighlightRewriter implements HTMLRewriterElementContentHandlers { }, } ); + if (!res.ok) { + // Something went wrong with the request, just return the original code + text.replace(`${this.code}`, { html: true }); + return; + } const data = await res.text(); this.runtime.ctx.waitUntil(this.cache.put(key, data)); text.replace(data, { html: true });