Now I created a file by node server like
const functions = require("firebase-functions")
const express = require("express")
/* Express */
const app = express()
app.get("/test", (request, response) => {
response.send("Hello from Express on Firebase!")
})
const api1 = functions.https.onRequest(app)
module.exports = {
api1
}
firebase.json
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
and I have deployed it to firebase hosting and try tried access it on firebase hosting the index.html show up to me but when I require the /test
it's return as 404.html page ! what's I'm missing ?
after updated firebase.json and added rewrites to
{
"hosting":
{
"public": "public",
"rewrites": [
{
"source": "/test",
"function": "app"
}
]
}
}
The answer
I must to structured my project files to -project (folder) ---functions (folder)(contains on all nodejs files) ---public (filder)