Nodejs newbie api question

I must be honest when I say I have really no idea on all this nodejs thing.
So I’m just trying my best on understand how this works.

I made an api and seems working on localhost:

But not on my digital ocean droplet:

The app is running and all it’s there:
image

Should I need to configure something else?

Thanks in advance

Seems that api values has not been deployed. Try to save all again and re deploy it

Thanks for the reply.
This image is actually the ftp, so it’s on the server

For more information, I’m not using docker
Just created a droplet, installed nodejs, started the server via pm2 index.js
And uploading it via sftp

All files you want to be publicly accessible need to go inside folder public

Thanks @Apple
But that’s the way of using server connect?
If I move the api to public, I need to rename the server connect from
<dmx-serverconnect id="serverconnect1" url="/api/value"></dmx-serverconnect>
to
<dmx-serverconnect id="serverconnect1" url="/api/value.json"></dmx-serverconnect>

Edit: Ignore everything I wrote below, it’s completely incorrect

Click to see the incorrect advice

It’s very confusing to me what you’re trying to do, a Server Connect is to connect to a Server Action. Maybe you want to use “API Data Source” instead?

And yes, you need to “rename” to /api/value.json. I’m not sure why it worked on localhost without renaming… Something to do you with your web server configuration I guess.

Edit: MY BAD, sorry, let me think.

That’s exactly what I’m trying to do :slight_smile: :

Please excuse my lack of knowledge about this nodejs world

You’re right, you did everything right, sorry, forget about the public folder and renaming I mentioned earlier

All I can think are folder/file permissions are not set correctly, but this is just a theory, it’s very hard to know the problem you’re experiencing. Set folder/file permissions (chmod) to 777 to test

Done without success, same thing

1 Like

You need to restart the NodeJS app, files are loaded on start-up

2 Likes

You have no idea how grateful I am for your help!

I couldn’t have known that on my own, adding some beers for you on the list

A really and big thank you @Apple

Glad we solved the problem! You’re welcome!

Every time you update your app, you need to restart it. Maybe this was the problem since the beginning :exploding_head:

1 Like

Starting with version 18, node reloads automatically, just type node --watch index.js in the terminal

3 Likes

Definitely, the api was uploaded after the site was running without any server action, so it has all sense now.

Good to know, thanks for the advice.

Thanks @AdrianoLuiz I'll take note of this.

Never thought possible going with nodejs, this community make so simple everything, thanks both again.

3 Likes