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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
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 underengines
: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