Summer Bug Smash: Smash Stories 🐛🛹
My AI Spend Audit app worked perfectly locally—until I connected the frontend to MongoDB. Suddenly, every audit submission returned a 500, and the browser showed Failed to save audit. The weird part? The request sometimes took almost 30 seconds before failing.
I initially suspected my API payload or Mongoose model. I checked the request body, schema, and API route, but everything looked correct. The timeout finally pointed me toward the database connection rather than the frontend.
After debugging MongoDB Atlas connectivity and environment configuration, I fixed the connection issue and the API started persisting audits successfully.
But wait bro the chaos wasn't over yet. My new /audit/[id] report page returned a 404. The logs revealed that modern Next.js was treating dynamic params as a Promise. I was accessing params.id synchronously, so I changed the server component to await the params before querying MongoDB.






