From 31d06de35d3d28eb75150d67c5f6d72985622bbd Mon Sep 17 00:00:00 2001 From: JakeSCahill Date: Mon, 18 May 2026 15:28:20 +0100 Subject: [PATCH] fix: exclude static assets from markdown edge function Prevents 500 errors on JS, CSS, fonts, and images by skipping markdown processing for static assets. The edge function was incorrectly attempting to serve markdown versions of asset files when browsers sent Accept: text/plain headers. Fixes static asset loading failures causing: - autocomplete-js.js 500 errors - site.js and site.css 500 errors - Font files (Inter, IBM Plex Mono) 500 errors - SVG and image 500 errors Co-Authored-By: Claude Sonnet 4.5 --- netlify/edge-functions/serve-markdown.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netlify/edge-functions/serve-markdown.js b/netlify/edge-functions/serve-markdown.js index 4b7062d..bbb6409 100644 --- a/netlify/edge-functions/serve-markdown.js +++ b/netlify/edge-functions/serve-markdown.js @@ -2,6 +2,12 @@ export default async (request, context) => { const url = new URL(request.url); const acceptHeader = request.headers.get('accept') || ''; + // Skip static assets - let them through immediately + const staticAssetExtensions = ['.js', '.css', '.woff', '.woff2', '.ttf', '.otf', '.eot', '.svg', '.png', '.jpg', '.jpeg', '.gif', '.ico', '.webp', '.json', '.xml']; + if (staticAssetExtensions.some(ext => url.pathname.endsWith(ext))) { + return context.next(); + } + // Check if the request is asking for markdown or plain text const wantsMarkdown = acceptHeader.includes('text/markdown') || acceptHeader.includes('text/plain');