Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular SSR 17.2 feature conflicts with hosting rewrites #6855

Open
alexcibotari opened this issue Mar 8, 2024 · 5 comments
Open

Angular SSR 17.2 feature conflicts with hosting rewrites #6855

alexcibotari opened this issue Mar 8, 2024 · 5 comments

Comments

@alexcibotari
Copy link

[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

@alexcibotari alexcibotari changed the title Angular SSR feature conflicts with hosting rewrites Angular SSR 17.2 feature conflicts with hosting rewrites Mar 8, 2024
@aalej
Copy link
Contributor

aalej commented Mar 8, 2024

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.

@aalej aalej added the Needs: Author Feedback Issues awaiting author feedback label Mar 8, 2024
@alexcibotari
Copy link
Author

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

@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Mar 8, 2024
@leach-mrt
Copy link

leach-mrt commented Apr 4, 2024

I had the same issue with Next.js

FYI:

if (buildResult.rewrites) rewrites.push(...buildResult.rewrites);

@9kubczas4
Copy link
Contributor

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.

@alexcibotari
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants