[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [Help](/c/help/9) # 404 error app/api/user/route.ts with mongodb 81 views · 0 likes · 2 posts Dmat913 (@dmat913) · 2024-08-14 I'm creating next.js project with mongodb. I completed to deploy to vercel. but i have a problem. not working app/api/user/route.ts in deploy site. it is displayed 404 not found. but the data exist on mongodb and working on local. I don' know how to resolve it. ``` import { NextRequest, NextResponse } from "next/server"; import { connectDb } from "@/utils/database"; import { UserModel } from "@/models/userModel"; export const GET = async (request: NextRequest) => { try { await connectDb(); // get name from query const { searchParams } = new URL(request.url); const name = searchParams.get("name"); if (!name) { return NextResponse.json( { message: "message" }, { status: 400 } ); } const user = await UserModel.findOne({ name }); if (user) { return NextResponse.json({ message: "successful", user: user, }); } else { return NextResponse.json( { message: "failed" }, { status: 404 } ); } } catch (error) { return NextResponse.json( { message: "failed" }, { status: 500 } ); } }; ``` ↑this is my app/api/user/route.ts ``` import mongoose from "mongoose"; export const connectDb = async () => { try { await mongoose.connect(process.env.MONGODB_URI || ""); } catch (error) { console.log("error"); throw new Error(); } }; ``` this is my utils/database.ts ``` try { const response = await fetch( `${process.env.NEXT_PUBLIC_API_URL}/user?name=${encodeURIComponent( username )}`, { method: "GET", } ); const data = await response.json(); if (response.ok) { setUser(data.user); } else { setError(data.message); } } catch (error) { setError("failed"); } ``` What is the problem.... (sorry.. I'm a beginner for English.) Pauline P. Narvas (@pawlean) · 2024-08-15 Hi and welcome, @dmat913! We have a community post: https://community.vercel.com/t/debugging-404-errors/437 that may be helpful. :smile: Can you read through it and let us know if any of the suggestions help with your issue?