Skip to content
This repository was archived by the owner on May 15, 2019. It is now read-only.
This repository was archived by the owner on May 15, 2019. It is now read-only.

Firebase serve erroring on missing 404 #310

@tettoffensive

Description

@tettoffensive

I'm trying to follow along with the youtube videos (https://www.youtube.com/watch?v=7IkUgCLr5oA&t=1s&list=PLl-K7zZEsYLkPZHe41m4jfAxUi0JjLgSM&index=3) and I have a simple cloud function which uses express. It runs fine when I deploy, but I would like to iterate on it locally.

Steps to reproduce

  1. firebase serve --only functions --debug
[2019-02-27T23:28:50.511Z] Starting @google-cloud/functions-emulator
[2019-02-27T23:28:50.539Z] Parsing function triggers
Warning: You're using Node.js v11.10.0 but Google Cloud Functions only supports v6.11.5.
[2019-02-27T23:28:50.951Z] Error while deploying to emulator: Error: 404 page not found

Error: 404 page not found

    at new RequestError (/usr/local/lib/node_modules/firebase-tools/node_modules/googleapis/node_modules/google-auth-library/lib/transporters.js:34:42)
    at Request._callback (/usr/local/lib/node_modules/firebase-tools/node_modules/googleapis/node_modules/google-auth-library/lib/transporters.js:108:23)
    at Request.self.callback (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:185:22)
    at Request.emit (events.js:197:13)
    at Request.EventEmitter.emit (domain.js:446:20)
    at Request.<anonymous> (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:197:13)
    at Request.EventEmitter.emit (domain.js:446:20)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:285:13)
⚠  functions: Failed to emulate api
i  functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.

index.js:

'use strict';

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const express = require('express');
const app = express();

// GET /books
// Return all the recipe books
app.get('/books', async (request, response) => {
  admin.firestore().collection('books').get()
    .then(snapshot => {
      // Create array of books to return as json
      let books = []
      snapshot.forEach((childSnapshot) => {
        let item = childSnapshot.data()
        // Add the id of the object to the model
        item["id"] = childSnapshot.id;
        books.push(item);
      });
      response.send(books);
      return books;
    }).catch(error => {
      // Handle the error
      console.log(error);
      response.status(500).send(error);
    })
});

// Expose the API as a function
exports.api = functions.https.onRequest(app);

Environment details

  • OS: macOS 10.14.2
  • Node.js version: v11.10.0
  • npm version: 6.8.0
  • @google-cloud/functions-emulator version: not sure. using firebase 6.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions