Next.js api working on localhost but they dont work on netlify run build

Hi everyone,

I am facing an issue with my /api/* files. They work perfectly fine when I run them locally using npm run dev, and I get success responses across the board. However, when I run the build on Netlify, the site doesn’t seem to work, and I receive an internal server error when trying to use the APIs.

The site in question is Unfortunately, accessing the parts would be blocked without a login, so you can’t test it for yourself. I have checked the code on the repository, GitHub - joshua-mcfield99/star-inn, but I couldn’t find anything useful.

One thing I noticed is that the type is XML, which is incorrect as it should be JSON. Also, the image attached to this post shows that the API files are there but have zero content.

I am new to using next/api, so I am not sure if there is anything specific I need to do, like importing the APIs into specific pages, and why the type is different on build.

Can anyone help me spot what’s wrong with my code, or suggest a fix to the issue?

Thank you in advance for your help.

Hi @joshua-mcfield99,

Please try removing package-lock.json from your repo.

I will try this tomorrow thankyou for the reply :slight_smile:

@hrishikesh I removed the package-lock.json file and now get a warn there is no package-lock, surely thats not the issue here ?

Hey @joshua-mcfield99,

Where are you seeing that warning? Could you please share the link so we can see it?