Can't connect /api calls to Web Service Express, from my Static Site

Hi,
I followed steps from tutorial, but I can’t connect /api calls to my express Web Service.
My project is at:

Instead of redirection, I added 2 env variables:
REACT_APP_HOST: …
REACT_APP_PORT: 4001
so i get a call:
https://support-knowledge.onrender.com:4001/api/test
but I always get the response:
net::ERR_CONNECTION_TIMED_OUT

In my Web Service shell I tried:
curl -X POST 127.0.0.1:4001/api/test
and received the response: ‘Welcome to GeeksforGeeks’

Do you have any suggestion?

Regards!

Hi,

You didn’t mention which tutorial you’re following, but there are a few issues here:

Alan

Hi Alan,
Thanks for suggestions.
My site is: https://support-knowledge.onrender.com/
I found solution for my /api/* calls, setting my Web Service link to ‘Rewrite rules’:

/api/*
https://support-knowledge-service.onrender.com:5000/api/*
Rewrite

Best Regards !

Having that port number in the destination URL won’t work, you’ll need to remove that.

Alan

Hi Alan,

It works!
My Express Web Server listen on port: 5000
How otherwise will my ‘/app’ call would ended on this port?
Regards,
Slavko

The port you specify is only for internal communication between the Render proxy and your service instance (or between service in your account). Public URLs only respond to HTTPS, port 443, which doesn’t need to be specified as it’s the HTTPS default.

Alan

1 Like

OK, thanks, it works.
I learned something.
Regards!

Hi @SlavkoPar , could u please tell how were u able to remove deceptive site ahead warning from your website? When i deployed my service onrender.com, after few minutes i started getting this warning and i am not sure what caused it as the project was for purely personal project purpose… any advise would be much appreciated.

Thank you in advance

Hi atom19-i,
I don’t receive any of warnings on my site:
https://support-knowledge.onrender.com

I just set my Web Service link to ‘Rewrite rules’:

/api/*
https://support-knowledge-service.onrender.com/api/*
Rewrite

and

/* index.html Rewrite

Best Regards !

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.