Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP request with Express app fails GET #1281

Closed
codeekage opened this issue May 13, 2019 · 4 comments
Closed

HTTP request with Express app fails GET #1281

codeekage opened this issue May 13, 2019 · 4 comments

Comments

@codeekage
Copy link

codeekage commented May 13, 2019

[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
@google-oss-bot
Copy link
Contributor

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

@abeisgoat
Copy link
Contributor

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 abeisgoat self-assigned this May 13, 2019
@abeisgoat abeisgoat changed the title Fails to GET request with functions.https.onRequest and Express HTTP request with cors() fails GET May 13, 2019
@abeisgoat abeisgoat changed the title HTTP request with cors() fails GET HTTP request with Express app fails GET May 13, 2019
@samtstern
Copy link
Contributor

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

abeisgoat added a commit that referenced this issue May 13, 2019
abeisgoat added a commit that referenced this issue May 14, 2019
@abeisgoat
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants