I can't access on express route on Firebase HostingHow to configure rewrite rules inside firebase-hosting to route certain requests to cloud functions?image not deployed to firebase hostingHow to host nodeJS project to firebase?Can't reference public folder from node.js deployment with firebaseFirebase Cloud Functions with Firebase Hosting : firebase.json “rewrites”Firebase: Can't access css and js files while hosting a website on Firebase. Get this error: GET net::ERR_ABORTEDDeploy a Vue.js App with Firebase HostingFirebase Hosting not generate firebase.jsonHow to host Nodejs/Express backend on firebase?Firebase Functions predeploy: ignore folderhow to host node.js web app(containing multiple folders) on firebase through firebase hosting?
How can I use the arrow sign in my bash prompt?
How will losing mobility of one hand affect my career as a programmer?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Tiptoe or tiphoof? Adjusting words to better fit fantasy races
Student evaluations of teaching assistants
Applicability of Single Responsibility Principle
Why Were Madagascar and New Zealand Discovered So Late?
Will it be accepted, if there is no ''Main Character" stereotype?
Short story about space worker geeks who zone out by 'listening' to radiation from stars
Opposite of a diet
Is there a good way to store credentials outside of a password manager?
What defines a dissertation?
Can I Retrieve Email Addresses from BCC?
What does this 7 mean above the f flat
The baby cries all morning
Bash method for viewing beginning and end of file
Confused about a passage in Harry Potter y la piedra filosofal
How do I rename a LINUX host without needing to reboot for the rename to take effect?
Efficiently merge handle parallel feature branches in SFDX
What's a natural way to say that someone works somewhere (for a job)?
How does it work when somebody invests in my business?
What will be the benefits of Brexit?
Using parameter substitution on a Bash array
How do I keep an essay about "feeling flat" from feeling flat?
I can't access on express route on Firebase Hosting
How to configure rewrite rules inside firebase-hosting to route certain requests to cloud functions?image not deployed to firebase hostingHow to host nodeJS project to firebase?Can't reference public folder from node.js deployment with firebaseFirebase Cloud Functions with Firebase Hosting : firebase.json “rewrites”Firebase: Can't access css and js files while hosting a website on Firebase. Get this error: GET net::ERR_ABORTEDDeploy a Vue.js App with Firebase HostingFirebase Hosting not generate firebase.jsonHow to host Nodejs/Express backend on firebase?Firebase Functions predeploy: ignore folderhow to host node.js web app(containing multiple folders) on firebase through firebase hosting?
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 message is different now
The answer
I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)
firebase firebase-hosting
add a comment |
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 message is different now
The answer
I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)
firebase firebase-hosting
Can you include your firebase.json file please? Did you forget to set the rewrite?
– JeremyW
Mar 21 at 15:28
@JeremyW thanks for your interesting ,I have added a firebase.json file
– Mahmoud Niypoo
Mar 21 at 15:34
add a comment |
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 message is different now
The answer
I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)
firebase firebase-hosting
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 message is different now
The answer
I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)
firebase firebase-hosting
firebase firebase-hosting
edited Mar 21 at 19:33
Mahmoud Niypoo
asked Mar 21 at 15:26
Mahmoud NiypooMahmoud Niypoo
14511
14511
Can you include your firebase.json file please? Did you forget to set the rewrite?
– JeremyW
Mar 21 at 15:28
@JeremyW thanks for your interesting ,I have added a firebase.json file
– Mahmoud Niypoo
Mar 21 at 15:34
add a comment |
Can you include your firebase.json file please? Did you forget to set the rewrite?
– JeremyW
Mar 21 at 15:28
@JeremyW thanks for your interesting ,I have added a firebase.json file
– Mahmoud Niypoo
Mar 21 at 15:34
Can you include your firebase.json file please? Did you forget to set the rewrite?
– JeremyW
Mar 21 at 15:28
Can you include your firebase.json file please? Did you forget to set the rewrite?
– JeremyW
Mar 21 at 15:28
@JeremyW thanks for your interesting ,I have added a firebase.json file
– Mahmoud Niypoo
Mar 21 at 15:34
@JeremyW thanks for your interesting ,I have added a firebase.json file
– Mahmoud Niypoo
Mar 21 at 15:34
add a comment |
1 Answer
1
active
oldest
votes
You 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"
]
This answer isn't actually an answer to your question, but it demonstrates the proper way to set up rewrites with cloud function express apps.
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);
– Mahmoud Niypoo
Mar 21 at 15:44
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."
– Mahmoud Niypoo
Mar 21 at 15:55
@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.
– JeremyW
Mar 21 at 15:58
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
– Mahmoud Niypoo
Mar 21 at 16:03
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section,/test
SHOULD be showing your Hello message.
– JeremyW
Mar 21 at 16:30
|
show 5 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283914%2fi-cant-access-on-express-route-on-firebase-hosting%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You 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"
]
This answer isn't actually an answer to your question, but it demonstrates the proper way to set up rewrites with cloud function express apps.
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);
– Mahmoud Niypoo
Mar 21 at 15:44
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."
– Mahmoud Niypoo
Mar 21 at 15:55
@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.
– JeremyW
Mar 21 at 15:58
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
– Mahmoud Niypoo
Mar 21 at 16:03
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section,/test
SHOULD be showing your Hello message.
– JeremyW
Mar 21 at 16:30
|
show 5 more comments
You 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"
]
This answer isn't actually an answer to your question, but it demonstrates the proper way to set up rewrites with cloud function express apps.
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);
– Mahmoud Niypoo
Mar 21 at 15:44
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."
– Mahmoud Niypoo
Mar 21 at 15:55
@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.
– JeremyW
Mar 21 at 15:58
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
– Mahmoud Niypoo
Mar 21 at 16:03
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section,/test
SHOULD be showing your Hello message.
– JeremyW
Mar 21 at 16:30
|
show 5 more comments
You 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"
]
This answer isn't actually an answer to your question, but it demonstrates the proper way to set up rewrites with cloud function express apps.
You 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"
]
This answer isn't actually an answer to your question, but it demonstrates the proper way to set up rewrites with cloud function express apps.
answered Mar 21 at 15:38
JeremyWJeremyW
2,128716
2,128716
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);
– Mahmoud Niypoo
Mar 21 at 15:44
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."
– Mahmoud Niypoo
Mar 21 at 15:55
@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.
– JeremyW
Mar 21 at 15:58
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
– Mahmoud Niypoo
Mar 21 at 16:03
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section,/test
SHOULD be showing your Hello message.
– JeremyW
Mar 21 at 16:30
|
show 5 more comments
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);
– Mahmoud Niypoo
Mar 21 at 15:44
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."
– Mahmoud Niypoo
Mar 21 at 15:55
@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.
– JeremyW
Mar 21 at 15:58
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
– Mahmoud Niypoo
Mar 21 at 16:03
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section,/test
SHOULD be showing your Hello message.
– JeremyW
Mar 21 at 16:30
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);
– Mahmoud Niypoo
Mar 21 at 15:44
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);
– Mahmoud Niypoo
Mar 21 at 15:44
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."
– Mahmoud Niypoo
Mar 21 at 15:55
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."
– Mahmoud Niypoo
Mar 21 at 15:55
@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.– JeremyW
Mar 21 at 15:58
@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.– JeremyW
Mar 21 at 15:58
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– Mahmoud Niypoo
Mar 21 at 16:03
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– Mahmoud Niypoo
Mar 21 at 16:03
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section,
/test
SHOULD be showing your Hello message.– JeremyW
Mar 21 at 16:30
@MahmoudNiypoo Hmmm, well that doesn't make any sense to me - with your rewrites section,
/test
SHOULD be showing your Hello message.– JeremyW
Mar 21 at 16:30
|
show 5 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283914%2fi-cant-access-on-express-route-on-firebase-hosting%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you include your firebase.json file please? Did you forget to set the rewrite?
– JeremyW
Mar 21 at 15:28
@JeremyW thanks for your interesting ,I have added a firebase.json file
– Mahmoud Niypoo
Mar 21 at 15:34