I've a project with polymer 2.0 web app with polymerfire and published to firebase hosting using
firebase deploy
I've another project with a cloud function that acts on database trigger, and deployed it using
firebase deploy --only functions:updateOnChange
I've another project with a cloud function that is an express app with route mappings
GET /fns/register
,POST /fns/register
, andPUT /fns/register/confirm
. I've deployed this usingfirebase deploy --only functions:register
I've created the rewrite rules to map the routes /fns/**
to the register cloud function in my first project (the polymer one) in the firebase.json file. I see this as a current firebase limitation that we can't manage the rewrite rules from multiple projects.
Following is my firebase.json
in the 1st project (polymer project):
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "build/default/public",
"rewrites": [
{
"source": "/fns/**",
"function": "fns"
},
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Now my requests for /fns/register
are getting routed to my register
cloud function, but the res.sendFile
I wrote in the app is not working. it always says
TypeError: path must be absolute or specify root to res.sendFile
at ServerResponse.sendFile (/user_code/node_modules/express/lib/response.js:410:11)
at app.get (/user_code/index.js:28:13)
at Layer.handle [as handle_request] (/user_code/node_modules/express/lib/router/layer.js:95:5)
at next (/user_code/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/user_code/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/user_code/node_modules/express/lib/router/layer.js:95:5)
at /user_code/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/user_code/node_modules/express/lib/router/index.js:335:12)
at next (/user_code/node_modules/express/lib/router/index.js:275:10)
at expressInit (/user_code/node_modules/express/lib/middleware/init.js:40:5)
My log statements inside the code are not working and even if I am sending simple res.send(JSON.stringify({ a: 1 }, null, 3));
it still throws the same above error.
This means, my code is not getting executed or my libraries are not getting uploaded to my cloud function. I want to understand the deployment scoping/ architecture/ dependencies of the cloud functions vs the app.
In Google IO 2017, the repeated advice was to go and use microsrevice style of development for the apps, and not a single monolith. What I am following here is microservice style of development, but getting no where!
Kindly help me here.