last day (15 days later) » 

16:32
1
A: I can't access on express route on Firebase Hosting

JeremyWYou need to include a rewrites section to your firebase.json file. That tells the Firebase servers how to route any requests that come in... and right now, you aren't telling it anything. "hosting": { "rewrites": [ { "source": "**", "function": "api1" ...

and how about if I have several routes like const users= require('./routes/users'); const books= require('./routes/books'); app.use('/users', users); app.use('/books', books);
after I added the rewrites the message became different "404. That’s an error. The requested URL was not found on this server. That’s all we know."
@MahmoudNiypoo You mean that after you've added the rewrites, and you visit /test? or /? then you get the 404? Any other route other than /test will 404 because it isn't configured in your Express instance. If you had other routes then you'd just have to include them in your express setup, just like any other node.js project. The rewrite sends ALL requests (the double astrisk) to your express app at the moment.
in this moment I only have just one route/test that happened when call root / the index.html appear to men but when call `/test' the message that I added in top appear to me 404. That’s an error. The requested URL was not found on this server. That’s all we know
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section, /test SHOULD be showing your Hello message.
@MahmoudNiypoo I see your update - check your "function" value in your rewrite rule. You have app whereas you need api1
i don't know also where i'm wrong this is my url angular6test-1c758.firebaseapp.com check it maybe i don't see something
hello
16:33
Howdy
sorry for wast your time
Try updating your "function" value to api1 instead of app
No worries
I'm on lunch break at work, so you aren't really taking me from anything aside from browsing reddit
thanks, i'm trying now
const functions = require("firebase-functions")
const express = require("express")

/* Express */
const app = express();

app.get("/hello", (request, response) => {
return response.send("Hello from Express on Firebase!")
})

exports.myApp1 = functions.https.onRequest(app);
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "/test",
"function": "myApp1"
}
]
}
}
still exist
16:36
That looks correct to me, hmmm
OOOoohhhh
Caught something
if Should I install firebase function with hosting in firebase init
!
You have /hello here
what's it ?
app.get("/hello", (reque
16:37
But you're rewriting /test
no :(
it still exists
You updated your express app back to app.get('/test' then? Or did you change your rewrites to /hello?
const functions = require("firebase-functions")
const express = require("express")

/* Express */
const app = express();

app.get("/test", (request, response) => {
return response.send("Hello from Express on Firebase!")
})

exports.myApp1 = functions.https.onRequest(app);
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "/test",
"function": "myApp1"
}
]
}
}
Okay
this is my code now
16:41
When you asked "if Should I install firebase function with hosting in firebase init".... what did you mean? When you initalized your Firebase project, did you choose to enable both Hosting AND Functions?
Okay. And when you're deploying, you're just doing firebase deploy, correct?
Now i install hosting only with out functions
yes
Hmmm, okay... thinking.... not sure what could be going wrong here... it looks like you've set everything up correctly...
mmm, I think so , thanks Jeremy for your help i will try to search on internet maybe i found something I missing
16:45
Hey
Got a result
angular6test-1c758.firebaseapp.com gives a result... is that just your HTML file though?
yes this is index.html
Darn, thought I'd made progress :(
but when call /test route it's crashing i guess
hhhh
have a nice day and thanks for your help
Sorry I couldn't solve it
You too
no problem
16:50
Out of curiosity, what's the cloud function's deployed URL?

last day (15 days later) »