Firebase hosting using emulator not rewriting to destination

43 views Asked by At

Note the issue I'm having is with the firebase emulator

It appears that I am unable to rewrite a request where the requested URI is /baz to a JSON file called baz.json. I would expect that I should be able to rewrite such that the JSON content in the path to baz.json would be provided in the response.

I have the following example in my firebase.json:

{
  "emulators": {
    "hosting": {
      "host": "0.0.0.0",
      "port": 8888
    },
    "ui": {
      "enabled": true
    },
    "singleProjectMode": true
  },
  "hosting": {
    "public": "foo/bar",
    "ignore": [],
    "rewrites": [
      {
        "source": "/baz",
        "destination": "<path to baz.json here>",
      }
    ]
  }
}

For <path to baz.json here> I have tried the following:

  • absolute path
  • relative path

The result I get when running firebase emulators:start for both of the above is:

$ curl localhost:8888/baz       
                   
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /baz</pre>
</body>
</html>

I would expect to get the contents of the file baz.json (which is some arbitrary JSON; let's say {} for now).

0

There are 0 answers