I'm getting 500 internal server error on my next js app

Hello Everyone
I’m getting 500 internal server error on my next js rest api. It’s an API that is just reading JSON files from the local directory. My rest API is working fine on my pc but it’s working on netlify. Kindly help me to resolve this issue.

here’s the like to the code: Code_mode/pages/api at main · umerprogramm/Code_mode · GitHub

What site is this about?

it’s a blog site that I created for my audiense

I meant the site name or some info using which we can find and check the site.

here the like of the site: https://peaceful-lokum-7179e9.netlify.app/

You can check the logs here: Netlify App

You’re trying to connect to localhost, which won’t be possible.

I also try it by using https://peaceful-lokum-7179e9.netlify.app/api/blogs but it’s still not working

I don’t understand, why are you trying to access the API from the same site? Where exactly is the data for your blog? Could you explain your setup so I can suggest accordingly?

so basically it’s a next js app it’s a react framework for the backend and frontend. I made an API using next js API . In order to make the API in next js you just need to make a file and there you can write your node js code. So I did the same thing I made a file which name this blogs.js under the api folder and I’m just trying to access data from this file and my code is working fine on my pc

When I said I don’t understand, I meant that I can only imagine this use case:

Your site deploys an API called /api/blog which fetches the data from some external source and returns it to the client. In this case, your frontend would be trying to fetch the data from /api/blogs.

What I don’t understand in your setup is, why you’re trying to access /api/blogs from /api/blogs? Shouldn’t you be accessing that route from your client-side code? Inside the blog.js file, you should be connecting to some external API to fetch the data.