Node.js project works locally but not on server

I have a working node.js project using the API, but when deploying to server I get an error each time when submitting:
Error: Request failed with status code 401

I used the formal node,js example project from here:

Any ideas on fixing this issue?

HTTP 401 error is a result of failed authentication.

I would first confirm that your API key is being sent correctly with the request. Also check in the network tab of your browser’s devtools for a meaningful message in the HTTP 401 response.

Do you have a .env file on your server with the api key in it?