From 88c075e146147839a044bc34e9e70d9c373fcb30 Mon Sep 17 00:00:00 2001 From: Juriba Date: Sat, 31 Aug 2024 22:56:13 +0300 Subject: [PATCH] hotfix --- apps/client/project.json | 56 +------------- apps/client/server.ts | 77 ------------------- .../src/app/shared/api-client.service.ts | 4 +- apps/client/tsconfig.server.json | 10 --- apps/server/src/shared/origins.ts | 2 +- 5 files changed, 5 insertions(+), 144 deletions(-) delete mode 100644 apps/client/server.ts delete mode 100644 apps/client/tsconfig.server.json diff --git a/apps/client/project.json b/apps/client/project.json index 132a3e7..b8812d8 100644 --- a/apps/client/project.json +++ b/apps/client/project.json @@ -10,7 +10,7 @@ "executor": "@angular-devkit/build-angular:browser", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/apps/client/browser", + "outputPath": "dist/apps/client", "index": "apps/client/src/index.html", "main": "apps/client/src/main.ts", "polyfills": ["zone.js"], @@ -97,60 +97,6 @@ "spa": true } }, - "server": { - "dependsOn": ["build"], - "executor": "@angular-devkit/build-angular:server", - "options": { - "outputPath": "dist/apps/client/server", - "main": "apps/client/server.ts", - "tsConfig": "apps/client/tsconfig.server.json", - "inlineStyleLanguage": "scss" - }, - "configurations": { - "production": { - "outputHashing": "media" - }, - "development": { - "buildOptimizer": false, - "optimization": false, - "sourceMap": true, - "extractLicenses": false, - "vendorChunk": true - } - }, - "defaultConfiguration": "production" - }, - "serve-ssr": { - "executor": "@angular-devkit/build-angular:ssr-dev-server", - "configurations": { - "development": { - "browserTarget": "client:build:development", - "serverTarget": "client:server:development" - }, - "production": { - "browserTarget": "client:build:production", - "serverTarget": "client:server:production" - } - }, - "defaultConfiguration": "development" - }, - "prerender": { - "executor": "@angular-devkit/build-angular:prerender", - "options": { - "routes": ["/"] - }, - "configurations": { - "development": { - "browserTarget": "client:build:development", - "serverTarget": "client:server:development" - }, - "production": { - "browserTarget": "client:build:production", - "serverTarget": "client:server:production" - } - }, - "defaultConfiguration": "production" - }, "docker-build": { "dependsOn": ["build"], "command": "docker build -f apps/client/Dockerfile . -t client" diff --git a/apps/client/server.ts b/apps/client/server.ts deleted file mode 100644 index b4d129b..0000000 --- a/apps/client/server.ts +++ /dev/null @@ -1,77 +0,0 @@ -import 'zone.js/node'; - -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'; - -// The Express app is exported so that it can be used by serverless Functions. -export function app(): express.Express { - const server = express(); - const distFolder = join(process.cwd(), 'dist/apps/client/browser'); - const indexHtml = existsSync(join(distFolder, 'index.original.html')) - ? join(distFolder, 'index.original.html') - : join(distFolder, 'index.html'); - - const commonEngine = new CommonEngine(); - - server.set('view engine', 'html'); - server.set('views', distFolder); - - // Example Express Rest API endpoints - // server.get('/api/**', (req, res) => { }); - // Serve static files from /browser - server.get( - '*.*', - express.static(distFolder, { - maxAge: '1y', - }) - ); - - // All regular routes use the Angular engine - server.get('*', (req, res, next) => { - const { protocol, originalUrl, baseUrl, headers } = req; - console.log(`SSR request: ${protocol}://${headers.host}${originalUrl}`); - - - commonEngine - .render({ - bootstrap, - documentFilePath: indexHtml, - url: `${protocol}://${headers.host}${originalUrl}`, - publicPath: distFolder, - providers: [ - { provide: APP_BASE_HREF, useValue: baseUrl }, - { provide: 'API_URL', useValue: process.env.API_URL } - ], - }) - .then((html) => res.send(html)) - .catch((err) => next(err)); - }); - - return server; -} - -function run(): void { - const port = process.env['PORT'] || 4000; - - // Start up the Node server - const server = app(); - server.listen(port, () => { - console.log(`Node Express server listening on http://localhost:${port}`); - }); -} - -// Webpack will replace 'require' with '__webpack_require__' -// '__non_webpack_require__' is a proxy to Node 'require' -// 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) || ''; -if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { - run(); -} - -export default bootstrap; diff --git a/apps/client/src/app/shared/api-client.service.ts b/apps/client/src/app/shared/api-client.service.ts index f68f325..7be520c 100644 --- a/apps/client/src/app/shared/api-client.service.ts +++ b/apps/client/src/app/shared/api-client.service.ts @@ -12,7 +12,9 @@ import { environment } from '../../environments/environment'; export class ApiClientService { private baseUrl = environment.apiUrl; - constructor(private http: HttpClient, private tokenService: TokenService) {} + constructor(private http: HttpClient, private tokenService: TokenService) { + + } private getHeaders(): HttpHeaders { const token = this.tokenService.getToken(); diff --git a/apps/client/tsconfig.server.json b/apps/client/tsconfig.server.json deleted file mode 100644 index 6f9cb49..0000000 --- a/apps/client/tsconfig.server.json +++ /dev/null @@ -1,10 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.app.json", - "compilerOptions": { - "outDir": "../../out-tsc/server", - "target": "es2019", - "types": ["node"] - }, - "files": ["src/main.server.ts", "server.ts"] -} diff --git a/apps/server/src/shared/origins.ts b/apps/server/src/shared/origins.ts index 234b5d8..234e8bb 100644 --- a/apps/server/src/shared/origins.ts +++ b/apps/server/src/shared/origins.ts @@ -1,5 +1,5 @@ export const ORIGINS = [ "https://34.1.32.26", "https://rnd-platform-client-app-p5qzcycuqa-ww.a.run.app", - "http://localhost:3000", + "http://localhost:4200", ]