From 85d7315e30e4a867493f5b6e3d4e23fc0fcd2c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20K=C3=BCng?= Date: Sat, 31 Jan 2026 17:41:47 +0100 Subject: [PATCH] feat(web) back-end routing --- docker-compose.deploy.yml | 2 +- frontend/angular.json | 17 +++++++++++++++-- .../src/app/calculator/calculator.component.ts | 4 +++- frontend/src/environments/environment.prod.ts | 4 ++++ frontend/src/environments/environment.ts | 4 ++++ frontend/src/index.html | 1 + 6 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 frontend/src/environments/environment.prod.ts create mode 100644 frontend/src/environments/environment.ts diff --git a/docker-compose.deploy.yml b/docker-compose.deploy.yml index 25ce0fb..14cdd1a 100644 --- a/docker-compose.deploy.yml +++ b/docker-compose.deploy.yml @@ -23,7 +23,7 @@ services: image: ${REGISTRY_URL}/${REPO_OWNER}/print-calculator-frontend:${TAG} container_name: print-calculator-frontend-${ENV} ports: - - "${FRONTEND_PORT}:80" + - "${FRONTEND_PORT}:8008" depends_on: - backend restart: unless-stopped diff --git a/frontend/angular.json b/frontend/angular.json index 9111a06..4f1cbbd 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -39,6 +39,19 @@ }, "configurations": { "production": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "budgets": [ { "type": "initial", @@ -50,8 +63,7 @@ "maximumWarning": "4kB", "maximumError": "8kB" } - ], - "outputHashing": "all" + ] }, "development": { "optimization": false, @@ -59,6 +71,7 @@ "sourceMap": true } }, + "defaultConfiguration": "production" }, "serve": { diff --git a/frontend/src/app/calculator/calculator.component.ts b/frontend/src/app/calculator/calculator.component.ts index 0e68c2a..fff56aa 100644 --- a/frontend/src/app/calculator/calculator.component.ts +++ b/frontend/src/app/calculator/calculator.component.ts @@ -20,6 +20,8 @@ interface QuoteResponse { }; } +import { environment } from '../../environments/environment'; + @Component({ selector: 'app-calculator', standalone: true, @@ -61,7 +63,7 @@ export class CalculatorComponent { this.error = ''; this.results = null; - this.http.post('http://localhost:8000/calculate/stl', formData) + this.http.post(`${environment.apiUrl}/calculate/stl`, formData) .subscribe({ next: res => { this.results = res; diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts new file mode 100644 index 0000000..c685c61 --- /dev/null +++ b/frontend/src/environments/environment.prod.ts @@ -0,0 +1,4 @@ +export const environment = { + production: true, + apiUrl: 'https://3d-fab.ch/api' +}; diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts new file mode 100644 index 0000000..837417a --- /dev/null +++ b/frontend/src/environments/environment.ts @@ -0,0 +1,4 @@ +export const environment = { + production: false, + apiUrl: 'http://localhost:8000' +}; diff --git a/frontend/src/index.html b/frontend/src/index.html index d4f82fb..80f28c2 100644 --- a/frontend/src/index.html +++ b/frontend/src/index.html @@ -2,6 +2,7 @@ + Frontend