Search code examples
firebasefirebase-storagefirebase-hosting

Firebase hosting config, rewrite everything but one url


Here's my firebase.json. I'm trying redirect /sitemaps to a dynamically generated sitemaps in Firebase Storage. Unfortunately rewrites wildcard for the rest of routes overwrites the redirection. How would be the best way to specify to rewrite everything but that one url?

    "redirects": [
      {
        "source" : "/sitemaps",
        "destination" : "https://firebasestorage.googleapis.com/v0/b/foo",
        "type" : 301
      }
    ],
    "rewrites": [
      {
        "source": "**",
        "function": "bar"
      }
    ]

Solution

  • one can negate the condition with a !, in order to exclude.

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