Today my API stopped working. No change was made in the code since August and it was working fine.
Runtime logs show this:
[api] [2024-10-28 14:32:11] Server running on port 3000
[api] [2024-10-28 14:33:37] undefined:1
[api] [2024-10-28 14:33:37] <html>
[api] [2024-10-28 14:33:37] ^
[api] [2024-10-28 14:33:37]
[api] [2024-10-28 14:33:37] SyntaxError: Unexpected token '<', "<html>
[api] [2024-10-28 14:33:37] <h"... is not valid JSON
[api] [2024-10-28 14:33:37] at JSON.parse (<anonymous>)
[api] [2024-10-28 14:33:37] at Response.json (file:///workspace/node_modules/node-fetch/src/body.js:149:15)
[api] [2024-10-28 14:33:37] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[api] [2024-10-28 14:33:37]
[api] [2024-10-28 14:33:37] Node.js v20.18.0
What could be the problem? Maybe some change in Digitalocean? Maybe the problem is the new Node v20?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey Victor! 👋
Indeed, recently, DigitalOcean App Platform may have updated to Node v20, and it could be introducing some differences in how your API handles JSON parsing or external requests.
If your app is not compatible with Node v20, you can specify the Node version in your package.json
file to ensure App Platform runs your app on a compatible version. Add this under engines
:
"engines": {
"node": "18.x"
}
This would set it to Node 18.x, which is stable and avoids potential compatibility issues with Node 20.
Let me know how it goes!
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.