HTTP functions

overview

Configure and establish a bare-bones REST-API endpoint, called an HTTP function. We use an Express.js like API. We respond with JSON, HTML, or plain text:

export const sayHello = onRequest((req, res) => {
    res.send("Hello from Firebase!")
})

add options

const options: HttpsOptions = {
    region: "europe-west1",
    cors: true,
}
export const sayHello = onRequest(options, (req, res) => {})

ExpressJS concepts and syntax

req and res objects have the shape of expressJS req and res objects. We can add middleware.

call the endpoint: standard HTTP request (not Firebase specific)

We read the function's URL at deploy time.

We consume endpoints like regular REST API endpoints. The deployed endpoint URLs look like this:

https://requestPlanet-x82jak2-ew.a.run.app
earlymorning logo

HTTP functions

overview

Configure and establish a bare-bones REST-API endpoint, called an HTTP function. We use an Express.js like API. We respond with JSON, HTML, or plain text:

export const sayHello = onRequest((req, res) => {
    res.send("Hello from Firebase!")
})

add options

const options: HttpsOptions = {
    region: "europe-west1",
    cors: true,
}
export const sayHello = onRequest(options, (req, res) => {})

ExpressJS concepts and syntax

req and res objects have the shape of expressJS req and res objects. We can add middleware.

call the endpoint: standard HTTP request (not Firebase specific)

We read the function's URL at deploy time.

We consume endpoints like regular REST API endpoints. The deployed endpoint URLs look like this:

https://requestPlanet-x82jak2-ew.a.run.app