Skip to content

Angular 19 SSR cloud functions ESM build #3645

Open
@chakrachi

Description

@chakrachi
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions