Next.js Discord

Discord Forum

Internal server error in API route

Unanswered
style posted this in #help-forum
Open in Discord
Hey, I've written api route to dynamically generate opengraph images, however I had to implement fallback as it seems like vercel cannot read public directory in functions. However now i get 500 whenever I call this endpoint, and I don't see any logs, what might be a cause? Code in comment.

7 Replies

on localhost it works fine btw with both fs and fetching image from external server
American Chinchilla
Its pretty hard to say what may cause that. I would try to wrap your API and fs in a try catch block
And log the error
You can also try to see if you get this error using npm start locally to create a local production
for some reason it's now working 😆 Thank you for your time!