diff --git a/frontend/README.md b/frontend/README.md index 1831a52..01e6a2f 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -1,27 +1,3 @@ -# Frontend +# Befor production deployment -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.3. - -## Development server - -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. - -## Code scaffolding - -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. - -## Build - -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. - -## Running unit tests - -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Running end-to-end tests - -Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. +Note that the baseURL is automatically defined by the `DevelopementStore.ts` store. diff --git a/frontend/src/store/DevelopmentStore.ts b/frontend/src/store/DevelopmentStore.ts index 48d11de..2bd5244 100644 --- a/frontend/src/store/DevelopmentStore.ts +++ b/frontend/src/store/DevelopmentStore.ts @@ -1,21 +1,29 @@ import { Injectable } from '@angular/core'; -import { BehaviorSubject } from 'rxjs'; -import { map } from 'rxjs/operators'; - -interface DevelopmentStoreState { - baseUrl: string; -} @Injectable({ - providedIn: 'root' + providedIn: 'root', }) -export class DevelopmentStore { - private state: BehaviorSubject = new BehaviorSubject({ - baseUrl: 'http://localhost/', - }); +/** + * THIS IS NOT A OBSERVABLE STORE. + * This store automatically identifies if the env is production or development. + * If this app is running on development mode, it will add port 80 to the base url. + */ +export class EnvironmentService { + private isDevelopment: boolean; + constructor() { + this.isDevelopment = location.port === '4200'; + } - get baseUrl() { - return this.state.asObservable().pipe(map(state => state.baseUrl)); + getIsDevelopment(): boolean { + return this.isDevelopment; + } + + getBaseUrl(): string { + if (this.isDevelopment) { + return 'http://localhost:80/'; + } else { + return window.location.origin; + } } }