Created
March 18, 2017 22:30
-
-
Save cdock1029/9f3a58f352663ea90f8b9675412c4aea to your computer and use it in GitHub Desktop.
firebase-functions express.js path fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = require('express')(); | |
// define your routes, etc ... | |
exports.route = functions.https.onRequest((req, res) => { | |
// https://some-firebase-app-id.cloudfunctions.net/route | |
// without trailing "/" will have req.path = null, req.url = null | |
// which won't match to your app.get('/', ...) route | |
if (!req.path) { | |
// prepending "/" keeps query params, path params intact | |
req.url = `/${req.url}` | |
} | |
return app(req, res) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cdock1029 How did you point the hosting to the function? I'm doing:
It doesnt' work for the index path. It only works for /** paths.
Is this part of this issue?