I am just getting into Express, operating using Cloud Functions and I am caught in an issue. I know that when running on my local machine, I can use:
app.listen(port1, hostname, () => console.log(`Express Server running at http://${hostname}:${port1}/`));
The above code, based on the documentation from Express, states that it creates a http.createServer object like you would using Vanilla Node.js.
My question though is, because Firebase is serverless, and gives you a dedicated IP, can I use the port and or hostname options?
I'd like to, it would be nice to navigate to mysite.com:1234/example_path or listen for requests from specific ports from the serverless platform.
If not, what does settings these values do? And from there, what are the default values if I do not set them manually? Can I set the script to listen on DEFAULT?
You don't get a dedicated IP address with Cloud Functions. The resolved IP address for your project's functions may change over time. You function may be running on many server instances at the same time, under the control of Cloud Functions.
You can't listen on some port in Cloud Functions. For HTTP type functions, Cloud Functions manages the listening for you, and you just handle the incoming requests.
If you want to write HTTP functions, you should start with the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With