jhonderson / actual-http-api

Basic Actual Budget API exposed through HTTP endpoints
MIT License
40 stars 9 forks source link

TypeError: injected.send is not a function #6

Closed jacopo-j closed 8 months ago

jacopo-j commented 8 months ago

Hi, and thank you for this project. I set up the API using a docker container, but when I try to call any API I get the following exception, which results in a 500 error:

actual_http_api_1  | Unknown error while interacting with Actual Api. See server logs for more information TypeError: injected.send is not a function
actual_http_api_1  |     at send (/usr/src/app/node_modules/@actual-app/api/dist/methods.js:34:21)
actual_http_api_1  |     at Object.downloadBudget (/usr/src/app/node_modules/@actual-app/api/dist/methods.js:53:12)
actual_http_api_1  |     at Budget (/usr/src/app/src/v1/budget.js:15:23)
actual_http_api_1  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
actual_http_api_1  |     at async /usr/src/app/src/v1/routes/index.js:10:27

Do you have any suggestion for debugging or investigating the issue? Thanks

jhonderson commented 8 months ago

Hello. Could you please post the version of your actual client and server ? (It should be under settings)

jacopo-j commented 8 months ago

Sure: Client version: v23.12.0 Server version: v23.12.1

jhonderson commented 8 months ago

I just did a clean installation of actual-http-api using docker in 2 types of OSs: Ubuntu and Synology, but I can't reproduce the issue you are describing, neither with unencrypted budgets nor encrypted ones. Try deleting the container and pulling the latest version again.

It's worth noticing that this image only supports linux/amd64 architectures for now.

jacopo-j commented 8 months ago

Upon further investigation, it looks like the issue was somehow related to the fact that the ACTUAL_SERVER_URL I was providing was behind a reverse proxy. By providing the direct URL to the Actual server, this works.

jhonderson commented 8 months ago

Awesome!

Just for future reference to anyone facing a similar issue, this may be also caused by running actual server and actual http api through docker in the same machine but in different docker networks. If both containers are in the same machine, make sure they are both using the host network, or they are using the same bridge network. If they are in different machines, the actual server url must be accessible from the actual http api docker container, obviously.