diff --git a/web/angular.json b/web/angular.json index 3cc1fef..996bfee 100644 --- a/web/angular.json +++ b/web/angular.json @@ -72,7 +72,8 @@ "buildTarget": "recetes-web:build:production" }, "development": { - "buildTarget": "recetes-web:build:development" + "buildTarget": "recetes-web:build:development", + "proxyConfig": "proxy.conf.json" } }, "defaultConfiguration": "development" diff --git a/web/proxy.conf.json b/web/proxy.conf.json new file mode 100644 index 0000000..d009cc5 --- /dev/null +++ b/web/proxy.conf.json @@ -0,0 +1,10 @@ +{ + "/api": { + "target": "http://localhost:8080", + "secure": false + }, + "/oauth2": { + "target": "http://localhost:8080/oauth2", + "secure": false + } +} \ No newline at end of file diff --git a/web/src/app/app.config.ts b/web/src/app/app.config.ts index 0cff8f3..4048749 100644 --- a/web/src/app/app.config.ts +++ b/web/src/app/app.config.ts @@ -5,6 +5,8 @@ import { routes } from './app.routes'; import { provideHttpClient } from '@angular/common/http'; import { BASE_PATH } from 'recettes-ng-client'; import { environment } from '../environments/environment'; +import { ApiModule, Configuration } from 'recettes-ng-client'; +import { AuthService } from './auth.service'; export const appConfig: ApplicationConfig = { @@ -12,6 +14,17 @@ export const appConfig: ApplicationConfig = { { provide: BASE_PATH, useValue: environment.apiUrl }, + { + provide: Configuration, + useFactory: (authService: AuthService) => new Configuration( + { + basePath: environment.apiUrl, + accessToken: authService.getAccessToken.bind(authService) + } + ), + deps: [AuthService], + multi: false + }, provideRouter(routes), provideHttpClient() ] diff --git a/web/src/app/app.module.ts b/web/src/app/app.module.ts deleted file mode 100644 index fc367a1..0000000 --- a/web/src/app/app.module.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { NgModule } from '@angular/core'; -import { ApiModule, Configuration } from 'recettes-ng-client'; -import { AuthService } from './auth.service'; -import { environment } from '../environments/environment'; - -@NgModule({ - imports: [ ApiModule ], - providers: [ - { - provide: Configuration, - useFactory: (authService: AuthService) => new Configuration( - { - basePath: environment.apiUrl, - accessToken: authService.getAccessToken.bind(authService) - } - ), - deps: [AuthService], - multi: false - } - ] -}) -export class AppModule {} \ No newline at end of file diff --git a/web/src/app/receipes-list/receipes-list.component.ts b/web/src/app/receipes-list/receipes-list.component.ts index 07b9cb4..44e13d5 100644 --- a/web/src/app/receipes-list/receipes-list.component.ts +++ b/web/src/app/receipes-list/receipes-list.component.ts @@ -1,13 +1,12 @@ import { Component, OnInit } from '@angular/core'; import { CommonModule, NgFor } from '@angular/common'; import { Receipe, ReceipeService } from 'recettes-ng-client'; -import { AppModule } from '../app.module'; import { environment } from '../../environments/environment'; @Component({ selector: 'app-receipes-list', standalone: true, - imports: [CommonModule, AppModule, NgFor], + imports: [CommonModule, NgFor], templateUrl: './receipes-list.component.html', styleUrl: './receipes-list.component.scss' }) diff --git a/web/src/environments/environment.development.ts b/web/src/environments/environment.development.ts index 3d4fdb6..b085812 100644 --- a/web/src/environments/environment.development.ts +++ b/web/src/environments/environment.development.ts @@ -1,3 +1,3 @@ export const environment = { - apiUrl: 'http://localhost:8080' + apiUrl: 'http://localhost:4200/api' };