Skip to content
Snippets Groups Projects
Commit efb587cb authored by Etienne LOUPIAS's avatar Etienne LOUPIAS
Browse files

fix express import in server.ts

parent 2f69e9dc
No related branches found
No related tags found
1 merge request!634Draft: Resolve "[Actualités] - Partage article via RS : image d'illus à la place du logo rés'in"
......@@ -2,7 +2,7 @@ import 'zone.js/node';
import { APP_BASE_HREF } from '@angular/common';
import { CommonEngine } from '@angular/ssr';
import * as express from 'express';
import express from 'express';
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import AppServerModule from './src/main.server';
......@@ -23,9 +23,12 @@ export function app(): express.Express {
// Example Express Rest API endpoints
// server.get('/api/**', (req, res) => { });
// Serve static files from /browser
server.get('*.*', express.static(distFolder, {
maxAge: '1y'
}));
server.get(
'*.*',
express.static(distFolder, {
maxAge: '1y',
}),
);
// All regular routes use the Angular engine
server.get('*', (req, res, next) => {
......@@ -61,7 +64,7 @@ function run(): void {
// The below code is to ensure that the server is run only when not requiring the bundle.
declare const __non_webpack_require__: NodeRequire;
const mainModule = __non_webpack_require__.main;
const moduleFilename = mainModule && mainModule.filename || '';
const moduleFilename = (mainModule && mainModule.filename) || '';
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
run();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment