why am i getting a 404 when trying specific routes in URL with firebase hosting?

879 views
Skip to first unread message

Brian Q

unread,
Sep 28, 2022, 9:58:08 AM9/28/22
to Firebase Google Group
Hello,

So we have 2 react applications in one project. each application has its own folder.
I am able to host both applications in the same firebase project on two different domains.
But when we try and type in a specific route in the URL we get a 404. 

From everything we have looked up online our firebase.json file seems to be correct, but it seems firebase isnt finding or we arent pointing to the correct place. please help, our firebase.json file is below.


Screen Shot 2022-09-28 at 9.48.52 AM.png

Alan Escobar Martinez

unread,
Sep 30, 2022, 12:21:11 PM9/30/22
to fireba...@googlegroups.com
Hello Brian, 

From what I can see, all of the requests are being redirected to the index.html, and that is because you are using that last re-write instruction in your Firebase.json. There is an additional thing to consider here, but please consider that I'm not familiar with react; if the tool is using something that acts as a middleware for redirections and access to certain files, you should configure this as well.

If at the end of these tasks you are still experiencing issues, please feel free to reach out to Support,they could find ways to replicate the issue and help you to solve it.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/28e8db82-5f53-4f84-b64c-defe6f03031dn%40googlegroups.com.


--
EPAM_LOGO_Full_Color_RGB.png

Alan Escobar Martínez

Technical Solutions Engineer

Service provided by EPAM Systems, on behalf of Google

Michael Bleigh

unread,
Sep 30, 2022, 12:42:13 PM9/30/22
to Firebase Google Group
Hi Brian,

Your firebase.json is not properly formed - you have rewrites at the top level when they need to be nested within each of the Hosting site configs. Try something like this instead:

{
  "hosting": [
    {"target": "b2b", "public": "build/b2b", "rewrites": [{"source": "**", "destination": "/index.html"}]},
    {"target": "b2c", "public": "build/b2c", "rewrites": [{"source": "**", "destination": "/index.html"}]}
  ]
}

Brian Quezada

unread,
Sep 30, 2022, 4:37:02 PM9/30/22
to fireba...@googlegroups.com
That fixed it!!!! Thanks!!!

From: 'Michael Bleigh' via Firebase Google Group <fireba...@googlegroups.com>
Sent: Friday, September 30, 2022 12:41:43 PM
To: Firebase Google Group <fireba...@googlegroups.com>
Subject: Re: [Firebase] why am i getting a 404 when trying specific routes in URL with firebase hosting?
 
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/T3qcgKCCEwI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/CANPY8KWXTXbQevKc6La0xr6rDiFj1oA%2Br%2BQ3SRJ6xxEZzZnP0Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages