[angular-18]: Update library and assets. Update node version. Use withFetch App module. Fix server.ts
This commit is contained in:
parent
349184a813
commit
142105f19a
|
@ -54,7 +54,7 @@
|
|||
"@types/express": "^4.17.0",
|
||||
"@types/jasmine": "~3.6.0",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"@types/node": "^16.18.50",
|
||||
"@types/node": "^18.19.1",
|
||||
"browser-sync": "^3.0.0",
|
||||
"codelyzer": "^6.0.0",
|
||||
"jasmine-core": "~3.8.0",
|
||||
|
|
28
server.ts
28
server.ts
|
@ -1,12 +1,12 @@
|
|||
|
||||
import 'zone.js/node';
|
||||
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { CommonEngine } from '@angular/ssr';
|
||||
import {APP_BASE_HREF} from '@angular/common';
|
||||
import {CommonEngine} from '@angular/ssr';
|
||||
import * as express from 'express';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import bootstrap from './src/main.server';
|
||||
import {existsSync} from 'node:fs';
|
||||
import {join} from 'node:path';
|
||||
import {AppServerModule} from './src/app/app.server.module';
|
||||
import {REQUEST, RESPONSE} from "./src/app/openaireLibrary/utils/tokens";
|
||||
|
||||
// The Express app is exported so that it can be used by serverless Functions.
|
||||
export function app(): express.Express {
|
||||
|
@ -30,19 +30,23 @@ export function app(): express.Express {
|
|||
|
||||
// All regular routes use the Angular engine
|
||||
server.get('*', (req, res, next) => {
|
||||
const { protocol, originalUrl, baseUrl, headers } = req;
|
||||
const {protocol, originalUrl, baseUrl, headers} = req;
|
||||
|
||||
commonEngine
|
||||
.render({
|
||||
bootstrap,
|
||||
inlineCriticalCss: false,
|
||||
bootstrap: AppServerModule,
|
||||
documentFilePath: indexHtml,
|
||||
url: `${protocol}://${headers.host}${originalUrl}`,
|
||||
publicPath: distFolder,
|
||||
providers: [
|
||||
{ provide: APP_BASE_HREF, useValue: baseUrl },],
|
||||
{provide: APP_BASE_HREF, useValue: baseUrl},
|
||||
{provide: REQUEST, useValue: (req)},
|
||||
{provide: RESPONSE, useValue: (res)}
|
||||
]
|
||||
})
|
||||
.then((html) => res.send(html))
|
||||
.catch((err) => next(err));
|
||||
.then((html) => res.status(200).send(html))
|
||||
.catch((err) => res.status(500).send('Error during SSR'))
|
||||
});
|
||||
|
||||
return server;
|
||||
|
@ -67,5 +71,3 @@ const moduleFilename = mainModule && mainModule.filename || '';
|
|||
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
|
||||
run();
|
||||
}
|
||||
|
||||
export default bootstrap;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {APP_ID, NgModule} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from "@angular/common/http";
|
||||
import {HTTP_INTERCEPTORS, provideHttpClient, withFetch} from "@angular/common/http";
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {AppComponent} from './app.component';
|
||||
|
@ -52,7 +52,7 @@ import {HelperModule} from "./openaireLibrary/utils/helper/helper.module";
|
|||
},
|
||||
[{ provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true }],
|
||||
[{ provide: DEFAULT_TIMEOUT, useValue: 30000 }],
|
||||
provideHttpClient(withInterceptorsFromDi())
|
||||
provideHttpClient(withFetch())
|
||||
] })
|
||||
//
|
||||
export class AppModule {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit af31fcfc372e314637b24a1646db013edf19bdec
|
||||
Subproject commit ace2fca2e91eacd00cb7e2fcac4efa711d77a246
|
|
@ -1 +1 @@
|
|||
Subproject commit eb0051dc347cdaa44476048dea9f6b61200f257f
|
||||
Subproject commit a88e24accc23599b43577994011e424eb693e817
|
Loading…
Reference in New Issue