I have a simple api exposed on port 8001 below through fastapi/python. The api works fine through curl. But when I try to access it from my react frontend(http://frontend-core.fly.dev/) or postman, I get an error ERR_CONNECTION_RESET. Fly logs for backend doesnt show any activity
Thank you for your continued help on this. The backend api is exposed on port 8001, so the request url looks correct to me. When I run the same code for backend and frontend on my local machine, everything works fine. The only difference in setup in that fly.to is using https, while on local testing I was using http.
The backend API may be running on port 8001, but presumably that is mapped (using fly.toml) to port 443 so that it can be served as https. See Fly Launch configuration (fly.toml) · Fly Docs for details.
There are two ways to proceed here. Either change your react frontend to issue requests when run in production to port 443 or use Private Networking · Fly Docs to connect directly to the backend. In that case you would indeed use port 8081, but you would use http (not https) and you would connect to fastapi-core.fly.internal instead of fastapi-core.fly.dev