I am trying to implement a firebase hosting rewrite. Here is my firebase.json
{
"functions": {},
"hosting": {
"public": "public",
"rewrites": [
{
"source": "/users",
"function": "usersMicroservice"
}
],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
My functions/index.js file looks like this
const functions = require("firebase-functions");
const express = require("express");
const app = express();
app.get("/users", (req, res) => res.json({message: "hello world"}));
app.get("/users/next", (req, res) => res.json({message: "hello world 2"})));
exports.usersMicroservice = functions.https.onRequest(app);
I am running my server locally. There are two urls that appear in the logs. They are
http://localhost:5001/test-development/us-central1/usersMicroservice
and
The first url is the direct path to my cloud function and the latter is my "hosting" url. When I make a requests to the cloud function everything works as expected. However, when I make a GET request to http://localhost:5000/users/1 I get a 404 Page Not Found message, but when I make a GET request to http://localhost:5000/users I get the expected json response.
I am new to firebase hosting and cloud functions. Not sure what I might be doing incorrectly. Any help is greatly appreciated.