API connection error

#1

Hello there, i have built a small API using adonisJS and deployed it on a my server, which works fine both locally and on the server.

I also built a frontend to consume the API using Laravel, this works well on my local machine, but once deployed on the server. It stops connecting to the API

find my config below

server: nginx
adonisVersion: 4.1.0
laravelVersion: 5.8
phpFPM: 7.1
O.S: ubuntu-16.04

Thanks for your help in advance.

0 Likes

#2

Hello @iamtunde

A lot of information lacking from here :slightly_frowning_face:

But most likely the case: Laravel’s production (server) Adonis API URL is wrong?
You can set it in .env or in some config files where you have it set in your code.

Also when config is cached you have to reset Laravel config cache. You can do it with php artisan. I don’t remember exact command

0 Likes

#3

hi @McSneaky

I’ve cross checked the API URL and cleared cache it’s still the same, no error logs on both ends.

you can try here
http://34.238.235.27/horus/core/login

use a valid email and any password

0 Likes

#4

Hi @iamtunde

Can you access API directly with browser?

Is your API on same machine and just on different port or is it on other address?

Maybe there is firewall on API server blocking access to it?

Or perhaps you can edit Laravel code in production, make some sort of test endpoint, that just returns API URL as string, so you can check, if it is what it is expected to be.

0 Likes

#5

@McSneaky, thanks for your response I’ve eventually realised what the problem is.

It was actually an environment problem of the frontend, connecting to the API server on HTTPS via cURL, I had to put some security measures in place.

Thanks once again.

0 Likes