From 54625124d9db6c83ae25f09bfe053ff0f8aa938a Mon Sep 17 00:00:00 2001 From: Christopher Lindsay Date: Tue, 27 Feb 2024 11:04:21 -0500 Subject: [PATCH] chore: troubleshooting --- frontend/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/index.js b/frontend/index.js index 1a3fd8cb0b..1d08af6fea 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -10,21 +10,21 @@ Bun.serve({ console.log("Resolved file path:", filePath); try { - // Check if the requested URL is the root - if (url.pathname === "/") { - // If root, serve the index.html file + // Check if the requested file exists + const fileExists = await Bun.file.exists(filePath); + if (fileExists) { + // If the file exists, serve it + const file = Bun.file(filePath); + return new Response(file); + } else { + // If the file doesn't exist, serve the index.html file const indexFilePath = BASE_PATH + "/index.html"; const indexFile = Bun.file(indexFilePath); return new Response(indexFile); - } else { - // Otherwise, attempt to fetch the file - const file = Bun.file(filePath); - // Return the file if it exists - return new Response(file); } } catch (error) { console.error("Error occurred while fetching file:", error); - // If the file doesn't exist, serve the index.html file + // If any error occurs, serve the index.html file const indexFilePath = BASE_PATH + "/index.html"; const indexFile = Bun.file(indexFilePath); return new Response(indexFile);