functions-framework-nodejs
functions-framework-nodejs copied to clipboard
feat: added new option to change the server host
I am using this package to test my function and noticed something curious: I wasn’t able to access my function from inside a Docker container. I was using http://host.docker.internal:3000 and it returned a "connection refused" error. I ran a test trying to access my frontend, which was also running locally (but with the host set to 0.0.0.0), and I was able to access it normally.
To work around the issue, I ran my container using "network_mode": "host" (in the docker-compose file), so everything was on the same network and it worked perfectly. However, to avoid this adjustment and make everything simpler, I decided to suggest this change.
- Run a function locally
- Create any Ubuntu container
- Execute inside the container and try to access your application using http://host.docker.internal:3000 (should return connection refused)
- As a test, try accessing any other server where you have the option to set 0.0.0.0