Search code examples
node.jsfirebaseexpressgoogle-cloud-functionsfirebase-cli

Running Firebase Functions locally with secure connections (HTTPS)


I have a react app served with HTTPS (I need it for a service worker running in the background) that is having CORS issues with my backend running locally with Firebase Functions.

Firebase Functions is just wrapping an express application with CORS module enabled. I performed a few tests with OPTIONS calls to this backend and I'm getting the proper headers.

They problem is that my Frontend (HTTPS) cannot reach out to my backend (HTTP). Is there any way to run firebase functions locally with HTTPS instead of HTTP?

running firebase serve --help only shows

Options:
  -p, --port <port>   the port on which to listen (default: 5000) (default: 5000)
  -o, --host <host>   the host on which to listen (default: localhost) (default: "localhost")
  --only <targets>    only serve specified targets (valid targets are: hosting, functions, database, firestore)
  --except <targets>  serve all except specified targets (valid targets are: hosting, functions)
  -h, --help          output usage information

Solution

  • The local emulator does not support HTTPS at this time. T here is a thread on GitHub about this, with advice to use ngrok for a similar use case. https://github.com/firebase/firebase-tools/issues