Skip to content

Commit

Permalink
chore: troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-chris committed Feb 27, 2024
1 parent c9e377b commit 5462512
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5462512

Please sign in to comment.