API Action working on front and not working in Server Action

Wappler Version : last stable
Operating System : MacOS Sonoma
Server Model: NodeJS
Database Type: DO PostgreSQL
Hosting Type: Custom hosting

On the same page, GET requests on load are executed normally, but a similar GET request returns a 500 error. This all works on localhost, but on the production server it throws an error

The checkbox Pass Errors is ticked, the 500 error is coming from the remote API you’re calling, does the response tells you any detail?

The problem here is clearly not in the external request - even when I disable it and leave simple operations with variables - the result is the same - 500 error

Like Apple says, can you show the response/preview tabs and expand the error message?
Also check the console and share some post here please

The response contains only this message, regardless of whether I enable DEBUG and the Pass Error flag

Have you deployed after enabling the debug mode? And make sure you turned the debug mode on the production (remote) server target instead of the local one

how to enable debug mode on a production server?

Just turn it on and check the error, after that turn it off again.

Also

Check the publish button if there’s something missing on your server

yes, I enable this option, but still no additional information appears

Sorry maybe I’m not following you.
You enable the debug mode on your production server and still seeing “to see the error enable the debug flag”?

The steps are:

  1. Enable the debug mode
  2. Hit publish to upload the files (as it is a config file that has changed) on your production server
  3. Check the error
  4. Disable the debug option
  5. Publish again

I’ve done it several times, but it doesn’t change anything. I have a strange problem with updating files on the server - there is a folder /app in the root - it is updated when the project is loaded, but there is also a folder /public/app - and that is what is updated. Is this a normal behaviour? - I don’t really understand the role of this folder.

I’m not a full nodejs person (at least not yet).

If you’re uploading your site via ftp check the remote folder under the target options.

there all the downloads go to the root directory, so everything seems to be ok with that

Okay with that, but as far as I know, if you enable debug mode and then publish your site (uploading the config file) you should be able to see what’s the error.
If you are uploading it and you still see that you need to enable debug mode is because the config file is not properly updated.
I don’t know how to help, a 500 error could be anything.

I did a simple experiment - I made two same API Actions that consist of one command to call an external API - one on the front-end, the second on the back-end in a Server Action. And I launched it on a local server and on product hosting. On local, both methods work, but on product Server Action it does not work.



This might be the key to solving the issue. On the remote server, how is the nodejs set up? Is it pointed to /app in the root or /public/app ?

If it is pointed to /app, then there is something going on. If it is pointed to /public/app, then you might need to check your Wappler publish settings to make sure it is pointed there as well.

Sorry, I don’t quite understand where I should and what to check.
I have these settings and I’m a little confused by the fact that in the local root folder it is /public - I don’t know - is this how it should be? In any case, it is impossible to change it - the SAVE button does not respond.

On the hosting https://vefkvartais.crmonster.online, where is the nodejs set up to point to?

When you set the nodejs up on the hosting (not in wappler), there should have been a setting to what directory is holding the files. That directory needs to match what you have in the VEF_prod - FTP - Remote Directory in wappler. Right now, from the screen shots, wappler is putting everything in the root directory.

The 500 error sounds like the files are in the wrong spot. Meaning the hosting is looking in one place and wappler put them somewhere else.

on the server, everything also goes to the root directory, and the rest of the project works fine, even on the same problematic page there are other server actions that are executed normally, the peculiarity here is that there is a call to an external API - the problem is somehow related to the operation of the API action - you don’t know which part of wappler is responsible for this?

After several days of experimentation, we managed to find a strange but working scheme. I created a website on PHP hosting and made a script on it to call an external API, that is, something like a proxy. That is, I first call the Server Action, from it a PHP script in which an external service is called, I receive a link to the generated PDF from there, and in the Server Action I download the file and send it to S3 storage. Oddly enough, this scheme works, unlike the direct one inside the Server Action.

@George I also noticed while I was looking for reasons that wappler does not update node modules on the hosting and sometimes there is simply no module for the corresponding project functions, especially for modules that are used in third-party extensions - maybe it’s worth making an option to load them when publishing?