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

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