I recently encountered an issue while trying to load CSS and JS files in my Express.js project. Despite following various methods, including setting up a static public folder and handling requests individually, I couldn't get the stylesheets and scripts to load properly.
After removing the code for the static public folder setup, I attempted different paths for linking the CSS and JS files directly in the index.html file. However, this resulted in MIME type errors and the files still failed to load correctly.
Even when placing the CSS and JS files next to the index.html file and adjusting the link paths accordingly, I continued to face the same issues with MIME types and loading errors.
At this point, I'm seeking guidance on resolving this problem without relying on app.use(express.static("public")). How can I ensure that the CSS and JS files are loaded correctly in my Express.js application? Any help would be greatly appreciated.