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
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.
You can check the logs here: Netlify App
You’re trying to connect to
localhost, which won’t be possible.
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
What I don’t understand in your setup is, why you’re trying to access
/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.