firebase-tools
firebase-tools copied to clipboard
Angular SSR 17.2 feature conflicts with hosting rewrites
[REQUIRED] Environment info
firebase-tools: 13.4.0
Platform: Windows 11
[REQUIRED] Test case
I have the next firebase.json configuration :
{
"hosting": {
"target": "example",
"source": ".",
"frameworksBackend": {
"region": "europe-west1",
"maxInstances": 1
},
"redirects": [
{
"source": "/",
"destination": "/home",
"type": 301
}
],
"rewrites": [
{
"source": "/api/**",
"function": "api",
"region": "europe-west6"
}
]
},
}
[REQUIRED] Steps to reproduce
Perform GET request to <firebase host>/api/users
[REQUIRED] Expected behavior
The request is receiving a response from the Firebase function
[REQUIRED] Actual behavior
The request is handled by Angular SSR frameworksBackend function
Hey @alexcibotari, thanks for reaching out. Sorry to hear you’re encountering this issue. By any chance, would you be able to share a minimal reproducible example with us, or detailed steps on how you set up your Angular project? This will help us with replicating the issue.
Hello @aalej
The most closest example that I have at the moment
https://codesandbox.io/p/devbox/naughty-wave-x4xqrs?file=%2Fsrc%2Fapp%2Fapp.routes.ts
I had the same issue with Next.js
FYI: https://github.com/firebase/firebase-tools/blob/d9d51e4f06c00853d9329376aba27712abc8d6d6/src/frameworks/index.ts#L331
Hi @alexcibotari,
Could you try to use the send method instead of return in the function? Like below:
const expressApp = express();
expressApp.use(cors({origin: true}));
expressApp.get("/api/users", async (req, res) => {
logger.info("users : " + JSON.stringify(req.params));
logger.info("users : " + JSON.stringify(req.query));
return res.send({message: "hello world"});
});
export const api = onRequest(expressApp);
Please let me know if it helps.
Hello @9kubczas4 ,
the result is the same. The response is coming from the SSR function created by Firebase, and not the function associated with the path in hosting.