Skip to content

Commit c03c1c5

Browse files
committed
ignoring /api in URls when on voxxr.in domain, so that we can have a similar behaviour
between "legacy" urls (https://us-central1-voxxrin-v3-demo.cloudfunctions.net) and custom voxxr.in domain urls (https://*.voxxr.in/)
1 parent 79e2e78 commit c03c1c5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cloud/functions/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ import * as express from 'express';
22
import * as functions from 'firebase-functions';
33
import {declareExpressHttpRoutes} from "./functions/http/api/routes";
44
import {extractSingleQueryParam} from "./functions/http/utils";
5+
import {info} from "./firebase";
56

67
const app = express()
78
app.use(express.json());
9+
app.use((req, res, next) => {
10+
if (req.headers['x-forwarded-host'] && req.headers['x-forwarded-host'].toString().endsWith("voxxr.in") && req.originalUrl.startsWith('/api')) {
11+
req.url = req.originalUrl.substring("/api".length);
12+
}
13+
next();
14+
})
815

916
// Legacy HTTP Endpoints declaration... please use declareRoutes() instead !
1017
exports.hello = functions.https.onRequest(async (request, response) => {

0 commit comments

Comments
 (0)