@@ -54,6 +54,10 @@ const getPrerenderedRoutes = async (outputDir) => {
54
54
const file = join ( outputDir , 'prerendered-routes.json' )
55
55
if ( ! existsSync ( file ) ) return [ ]
56
56
const { routes : prerenderedRoutes } = await readJson ( file )
57
+
58
+ // angular@19 returns an object with routes as keys
59
+ if ( ! Array . isArray ( prerenderedRoutes ) ) return Object . keys ( prerenderedRoutes )
60
+
57
61
return prerenderedRoutes
58
62
}
59
63
@@ -103,22 +107,15 @@ const setUpEdgeFunction = async ({ angularJson, constants, failBuild }) => {
103
107
104
108
const ssrFunction = `
105
109
import "./polyfill.mjs";
106
- import { Buffer } from "node:buffer";
107
- import { renderApplication } from " ${ toPosix ( relative ( edgeFunctionDir , serverDistRoot ) ) } /render-utils.server.mjs";
108
- import bootstrap from " ${ toPosix ( relative ( edgeFunctionDir , serverDistRoot ) ) } /main.server.mjs";
110
+ import { ɵgetOrCreateAngularServerApp as getOrCreateAngularServerApp } from "${ toPosix (
111
+ relative ( edgeFunctionDir , serverDistRoot ) ,
112
+ ) } /main.server.mjs";
109
113
import "./fixup-event.mjs";
110
114
111
- const document = Buffer.from(${ JSON . stringify (
112
- Buffer . from ( html , 'utf-8' ) . toString ( 'base64' ) ,
113
- ) } , 'base64').toString("utf-8");
115
+ const app = getOrCreateAngularServerApp()
114
116
115
117
export default async (request, context) => {
116
- const html = await renderApplication(bootstrap, {
117
- url: request.url,
118
- document,
119
- platformProviders: [{ provide: "netlify.request", useValue: request }, { provide: "netlify.context", useValue: context }],
120
- });
121
- return new Response(html, { headers: { "content-type": "text/html" } });
118
+ return await app.render(request, context)
122
119
};
123
120
124
121
export const config = {
0 commit comments