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 a0c0f35..0000000 --- a/apps/client/server.ts +++ /dev/null @@ -1,66 +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'; - - -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); - - 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'] + '/api/v1' }, - ], - }) - .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 10ba9c4..f68f325 100644 --- a/apps/client/src/app/shared/api-client.service.ts +++ b/apps/client/src/app/shared/api-client.service.ts @@ -12,9 +12,7 @@ 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", ]