1

I'm just started out with Firebase Hosting and going through the Tutorial on Initialize a Firebase Project. When I proceed to firebase deploy, I had this error message:

> tsc

✔  functions: Finished running predeploy script.
i  database: checking rules syntax...
✔  database: rules syntax for database salesman-firebase001 is valid
i  firebase.storage: checking storage.rules for compilation errors...
✔  firebase.storage: rules file storage.rules compiled successfully
i  firestore: reading indexes from firestore.indexes.json...
i  cloud.firestore: checking firestore.rules for compilation errors...
✔  cloud.firestore: rules file firestore.rules compiled successfully
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled

Error: HTTP Error: 400, Must supply a non-empty glob/regex pattern with rewrite configuration

I had gone Configure rewrites, added the necessary components to my firebase.json. The updated code for hosting:

  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ {
      // Serves index.html for requests to files or directories that do not exist
      "source": "**",
      "destination": "/index.html"
    }, {
      // Serves index.html for requests to both "/foo" and "/foo/**"
      // Using "/foo/**" only matches paths like "/foo/xyz", but not "/foo"
      "source": "/foo{,/**}",
      "destination": "/index.html"
    }, {
      // A regular expression-based rewrite equivalent to the above behavior
      "regex": "/foo(/.*)?",
      "destination": "/index.html"
    }, {
      // Excludes specified pathways from rewrites
      "source": "!/@(js|css)/**",
      "destination": "/index.html"
    } ]
  },

Thanks for your time.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Angus
  • 3,680
  • 1
  • 12
  • 27
  • 1
    Try a process of elimination. Remove all the rewrites, then add each one separately until you figure out which one is causing the problem. – Doug Stevenson Jun 13 '20 at 15:35
  • 1
    @DougStevenson I have removed the regex and it's running, but still, no clue on why it return a HTTP Error: 400. Anyway thanks for your suggestion! – Angus Jun 14 '20 at 09:57
  • 1
    We're running into the same error, even with simplest regexes. No clue what's wrong. – RReverser Jun 18 '20 at 16:37
  • @DougStevenson I think supplying regex for any field in firebase.json is broken right now. I ran into this same issue for "headers" instead of "rewrites" and stumbled across this SO question with an answer whose config just contains "source" (globs). https://stackoverflow.com/questions/40375694/how-to-leverage-browser-caching-in-firebase-hosting Wanted to bring this to the firebase teams attention is all – devinm Jul 10 '20 at 04:45
  • If you have a bug report, contact Firebase support directly. https://support.google.com/firebase/contact/support – Doug Stevenson Jul 10 '20 at 04:48

0 Answers0