Browse Source

tls authorization disabled for dev

feature/ssr-migration-schematic
erdemcaygor 1 year ago
parent
commit
2f15543056
  1. 16
      npm/ng-packs/apps/dev-app/src/server.ts

16
npm/ng-packs/apps/dev-app/src/server.ts

@ -1,3 +1,4 @@
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
import 'zone.js/node'; import 'zone.js/node';
import { APP_BASE_HREF } from '@angular/common'; import { APP_BASE_HREF } from '@angular/common';
@ -23,9 +24,12 @@ export function app(): express.Express {
// Example Express Rest API endpoints // Example Express Rest API endpoints
// server.get('/api/**', (req, res) => { }); // server.get('/api/**', (req, res) => { });
// Serve static files from /browser // Serve static files from /browser
server.get('*.*', express.static(distFolder, { server.get(
maxAge: '1y' '*.*',
})); express.static(distFolder, {
maxAge: '1y',
}),
);
// All regular routes use the Angular engine // All regular routes use the Angular engine
server.get('*', (req, res, next) => { server.get('*', (req, res, next) => {
@ -39,8 +43,8 @@ export function app(): express.Express {
publicPath: distFolder, publicPath: distFolder,
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
}) })
.then((html) => res.send(html)) .then(html => res.send(html))
.catch((err) => next(err)); .catch(err => next(err));
}); });
return server; return server;
@ -61,7 +65,7 @@ function run(): void {
// The below code is to ensure that the server is run only when not requiring the bundle. // The below code is to ensure that the server is run only when not requiring the bundle.
declare const __non_webpack_require__: NodeRequire; declare const __non_webpack_require__: NodeRequire;
const mainModule = __non_webpack_require__.main; const mainModule = __non_webpack_require__.main;
const moduleFilename = mainModule && mainModule.filename || ''; const moduleFilename = (mainModule && mainModule.filename) || '';
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
run(); run();
} }

Loading…
Cancel
Save