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?













0















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
enter image description here




The answer




I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)










share|improve this question
























  • 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















0















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
enter image description here




The answer




I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)










share|improve this question
























  • 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













0












0








0








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
enter image description here




The answer




I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)










share|improve this question
















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
enter image description here




The answer




I must to structured my project files to
-project (folder)
---functions (folder)(contains on all nodejs files)
---public (filder)







firebase firebase-hosting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer























  • 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











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
);



);













draft saved

draft discarded


















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









1














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.






share|improve this answer























  • 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
















1














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.






share|improve this answer























  • 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














1












1








1







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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




















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현