Reputation: 37
Im trying to run an Express app into firebase, i'm following the steps of this official video:
Node.js apps on Firebase hosting crash course
My Express app is actually running on this URL
But on the video, the demostration is running on this url
So, i'm really confused about this, i'been made everything as the tutorial shows
this is my code on functions/index.js
const functions = require('firebase-functions');
const express = require('express')
const app = express()
app.get('/test', (req, res) => {
res.send(`Well if i'm reading this the app is working`)
})
exports.app = functions.https.onRequest(app)
And this is firebase.json
{
"hosting": {
"public": "public",
"rewrite":[{
"source": "/test",
"function": "app"
}],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
What i'm doing wrong? if i enter to localhost:5000 i just get the public static index.html, i just want to control the app by myself.
I hope you can give me a little help to get documented, thanks!
Upvotes: 0
Views: 1396
Reputation: 317968
The issue here is that Firebase Hosting will serve static content that matches any paths before using any rewrites. If you want to control a path with Cloud Functions, you will have to make sure that there is no static content that matches the path.
For single page apps in particular, it's critical to remove index.html, as that will always be served as static content.
Upvotes: 2