diff --git a/.changeset/calm-dragons-visit.md b/.changeset/calm-dragons-visit.md new file mode 100644 index 000000000000..d025ab17dbf7 --- /dev/null +++ b/.changeset/calm-dragons-visit.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: suppress console spam for chrome devtools requests diff --git a/packages/kit/src/runtime/server/respond.js b/packages/kit/src/runtime/server/respond.js index ad945974ef58..783c7d0ee65a 100644 --- a/packages/kit/src/runtime/server/respond.js +++ b/packages/kit/src/runtime/server/respond.js @@ -51,6 +51,8 @@ const page_methods = new Set(['GET', 'HEAD', 'POST']); const allowed_page_methods = new Set(['GET', 'HEAD', 'OPTIONS']); +let warned_on_devtools_json_request = false; + /** * @param {Request} request * @param {import('types').SSROptions} options @@ -573,6 +575,21 @@ export async function respond(request, options, manifest, state) { // if this request came direct from the user, rather than // via our own `fetch`, render a 404 page if (state.depth === 0) { + // In local development, Chrome requests this file for its 'automatic workspace folders' feature, + // causing console spam. If users want to serve this file they can install + // https://github.com/ChromeDevTools/vite-plugin-devtools-json + if (DEV && event.url.pathname === '/.well-known/appspecific/com.chrome.devtools.json') { + if (!warned_on_devtools_json_request) { + console.warn( + `\nGoogle Chrome is requesting ${event.url.pathname} to automatically configure devtools project settings. To serve this file, add this plugin to your Vite config:\n\nhttps://github.com/ChromeDevTools/vite-plugin-devtools-json\n` + ); + + warned_on_devtools_json_request = true; + } + + return new Response(undefined, { status: 404 }); + } + return await respond_with_error({ event, options,