Firebase-tools: HTTP request with Express app fails GET

Created on 13 May 2019  路  4Comments  路  Source: firebase/firebase-tools

[REQUIRED] Environment info


firebase-tools: v 6.9.2
nodejs v10.15.3
npm v6.9.0


Platform: Ubuntu

[REQUIRED] Test case

index.ts

import * as functions from 'firebase-functions';
import { app } from './api/hello.api';

export const api = functions.https.onRequest(app)

./api/app.ts

import * as cors from 'cors'
import * as express from 'express'

export const app = express()
app.use(cors())
app.get('/', (req, res)=> {
    try{
        res.send("Hello")
    }catch(error){
        res.send(error)
    }
})

[REQUIRED] Steps to reproduce

npm run serve

[REQUIRED] Expected behaviour

  • Execute GET request successfully

[REQUIRED] Actual behavior

  • Fails on localhost results to:

    • Cannot GET /<firebase-app-name>/us-central1/api

  • no ERROR in console and debug file.
  • Works perfectly on deployment
emulator-suite bug

All 4 comments

This issue does not seem to follow the issue template. Make sure you provide all the required information.

Hmm, I wonder if this has to do with stacking multiple cors() (we pull it in already for Callable requests). I'll investigate today, thanks for the well written report!

@abeisgoat I bet we just have not done a good job routing requests to function subpaths

Fix is merged in, please re-open if you're still experiencing this once 6.9.3 is out.

Was this page helpful?
0 / 5 - 0 ratings