0

https://github.com/Elliott-Chong/chatpdf-yt/issues/43

This is the github link of the issue.

The error is as follows:

FileUpload.tsx:22 
 
 POST http://localhost:3000/api/createchat 500 (Internal Server Error)
mutationFn  @   FileUpload.tsx:22
Promise.then (async)        
onDrop  @   FileUpload.tsx:53

I have tried debugging and i guess that the error is in the code:

mutationFn: async ({
      file_key,
      file_name,
    }: {
      file_key: string;
      file_name: string;
    }) => {
      const response = await axios.post("/api/createchat", {
        file_key,
        file_name,
      });
      return response.data;
      //console.log(response);
    },
  });

This is the route.ts file under /api/createchat

import { loadS3IntoPinecone } from "@/lib/pinecone";
import { NextResponse } from "next/server"; 
export async function POST(req: Request) {
    try {

        const body = await req.json();
        const {file_key, file_name} = body;
        console.log(file_key,file_name);

        const pages = await loadS3IntoPinecone(file_key);
        return NextResponse.json({ pages });

    } catch (error) {
        console.error(error);
        return NextResponse.json(
            {error: "internal server error"},
            {status: 500}
            );
    }   
}
1

1 Answer 1

0

In the image attached, your request is hitting the api having path as /api/create-chat.
But the function you provided to handle those requests has endpoint as /api/createchat.

Make them same and it should work.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes i have tried changing it. actually i changed the file name from create-chat to createchat i did the same for the file name and the path but its still showing the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.