Search code examples
firebaseurl-rewritingfirebase-hosting

Firebase Hosting rewrites not working properly


I currently have the following configuration:

// firebase.json   
{
        "hosting": [
            {
                "rewrites": [{
                    "source": "/articles{,/**}",
                    "destination": "/articles"
                },
                {
                    "source": "**",
                    "destination": "/index.html"
                }]
            }
        ]
 }

If I go to mysite.com/articles/<articleID> I'm taken to mysite.com when I'd expect to be taken to mysite.com/articles. What am I doing incorrectly?

I'm following this documentation.


Solution

  • I was able to resolve the issue after taking the following steps:

    1. Change my source from /articles{,/**} to /articles/**
    2. Change my destination from articles to articles.html which is a valid local file
    3. Realize that changes to firebase.json don't change the behavior of the Firebase Hosting emulator until it is restarted.