I have an express.js based cloud functions application on firebase in a function named api. To use a custom domain, I'm trying to use Firebase host rewriting to route a specific URL to a function. I follow the official documentation on Firebase cloud features and hosting here, https://firebase.google.com/docs/hosting/functions and have tried many combinations, including the following:
"rewrites": [
{
"source": "/api/**",
"function": "api"
}
]
"rewrites": [
{
"source": "/api/:path1/:dat1/dat",
"function": "api/:path1/:dat1/dat"
}
]
"rewrites": [
{
"source": "/api/path1/dat1/dat",
"function": "api"
}
]
"rewrites": [
{
"source": "/api/*/*/*",
"function": "api"
}
]
Unfortunately, this does not work for any possible combination. My express application has the following GET paths that I plan to use:
'/api/users/:userId/:userData'
'/api/users/:userId/:userData/json'
'/api/users/:userId/'
and others like them: userId and: userData are parameters in my request, as this works with express.js
https:
https:
, , .
EDIT:
, .
const functions = require('firebase-functions');
const express = require('express');
const app = express();
app.get('/users/:userId/:userData/json', (req, res) => {
}
exports.api = functions.https.onRequest(app);
2:
@DougStevenson
firebase.json,
{
"hosting": {
"rewrites": [
{
"source": "/api",
"function": "api"
}
],
"public": "public"
}
}
, .
, , , . ( SO, , ). 404.html index.html , . .
2:
, , :
rewrites : [
{
"source": "/users/**/**/json",
"function": "api"
},
{
"source": "/api/users/**/**/json",
"function": "api"
}
]
- :
app.get('/users/:userId/:userData/json', Foo)
, - , Uri .