Skip to content

Angular 19 SSR cloud functions ESM build #3645

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

Open
2 of 3 tasks
chakrachi opened this issue Apr 9, 2025 · 1 comment
Open
2 of 3 tasks

Angular 19 SSR cloud functions ESM build #3645

chakrachi opened this issue Apr 9, 2025 · 1 comment

Comments

@chakrachi
Copy link

chakrachi commented Apr 9, 2025

  • unable to serve/deploy ssr functions esm build artifacts with vanilla cloud functions
  • able to ng serve, ng build (build-angular:application), and node ./server.mjs
  • other functions unrelated to SSR are working (server backend) as intended

Heres my SSR setup:

universal.ts

import { onRequest } from 'firebase-functions/v2/https';
import { render } from '../../render.js';
import express, { Request, Response, NextFunction } from 'express';
import * as server from '../../../dist/stamp-app/server/server.mjs';
export const ssrApp = express() as any;

ssrApp.use(express.static('dist/stamp-app/browser'));
ssrApp.get('*', async (req: Request, res: Response, next: NextFunction) => {
	const ssr: any = await render(server, req, res, next);
	res.send(ssr);
});

export const universal = onRequest(
	{ maxInstances: 10, timeoutSeconds: 1200, cpu: 1, memory: '2GiB', region: ['us-central1'] },
	ssrApp
);

render.js

import { Request, Response, NextFunction } from "express";

export async function configServerApp(app: any, req: Request, res: Response, next: NextFunction) {
  //configure app here & retrieve HTML
  let template;
  if (req.path === '/') {
    // template = await fetch('@dist/stamp-app/browser/index.csr.html');
    next();
  }
  template = `<div>HTML CONTENT FOR SSR APP</div>`;
  return template;
}
export async function render(app: any, req: Request, res: Response, next: NextFunction) {
  const ssrApp = await configServerApp(app, req, res, next);
  return ssrApp;
}

am I missing something..? thanks for any help in advance

@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

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

No branches or pull requests

2 participants