Hey all! I'm struggling to make this happen. I am moving to a database and want to configure everything correctly. Currently local is kind of working but staging deploys aren't.
Connections to db are working well.
app/api/get/route.ts
import type { NextApiRequest, NextApiResponse } from "next";
import { connectMongoDB } from '@/lib/mongodb';
import Product from "@/models/ProductModel";
import { NextResponse } from "next/server";
import mongoose from "mongoose";
export async function GET() {
console.log("hit get post", new Date().getSeconds());
try {
await connectMongoDB();
const get = await Product.find({}).limit(60);
return new NextResponse(JSON.stringify(get));
} catch (error) {
console.log("error from route", error);
return new NextResponse("Error");
}
}```
models/ProductModel.ts
```ts
import mongoose from "mongoose";
const Product = new mongoose.Schema();
module.exports = mongoose.models.Product || mongoose.model("Product", Product);
The error on staging deploys is: Type error: Module '"/vercel/path0/models/ProductModel"' has no default export.