5

I have a route https://playlists-22855.firebaseapp.com/client/create that when trying to access by clicking on the "Topics" link, I can get to just fine. But when I try to access that route directly by way of the address bar, I get a 404 error. I was wondering how to correct my code, which can be found here on codesandbox. Another funny thing is that the code runs just fine on codesandbox as expected, but there it's a create react app app, whereas mine is not. Thank you.

1
  • There's a difference between Server-side and Client-side. Take a look at stackoverflow.com/a/36623117/905571 and see if that solves your problem Commented Apr 23, 2018 at 6:37

1 Answer 1

11

I had this problem too - I fixed it by configuring my app as a single page app. When you originally did firebase init you could have selected this as an option. Now, you can do that by manually changing your firebase.json file.

You want to add this to your firebase.json

"rewrites": [
  {
    "source": "**",
    "destination": "/index.html"
  }
]

so your firebase.json will look something like this

{
  "hosting": {
    "target": "your-app-name",
    "public": "your-build-directory",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.