From 0cb0d4e1d106bb901a1f30cf0c16f57ee5d0c3de Mon Sep 17 00:00:00 2001 From: Juriba Date: Sat, 31 Aug 2024 22:56:13 +0300 Subject: [PATCH] hotfix --- apps/client/nginx.conf | 11 +++++++---- apps/client/project.json | 6 ++++++ apps/client/server.ts | 5 ++++- apps/client/src/app/shared/api-client.service.ts | 2 ++ apps/client/src/environments/environment.prod.ts | 2 +- apps/server/src/shared/origins.ts | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/apps/client/nginx.conf b/apps/client/nginx.conf index 7c624c9..7937724 100644 --- a/apps/client/nginx.conf +++ b/apps/client/nginx.conf @@ -29,10 +29,13 @@ http { try_files $uri $uri/ /index.html; } - location ~* ^(?!/assets/).*$ { - try_files $uri $uri/ /index.html; + location /api { + proxy_pass https://rnd-platform-server-app-p5qzcycuqa-ww.a.run.app; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; } - - error_page 404 /index.html; } } diff --git a/apps/client/project.json b/apps/client/project.json index 87b520b..132a3e7 100644 --- a/apps/client/project.json +++ b/apps/client/project.json @@ -27,6 +27,12 @@ }, "configurations": { "production": { + "fileReplacements": [ + { + "replace": "apps/client/src/environments/environment.ts", + "with": "apps/client/src/environments/environment.prod.ts" + } + ], "budgets": [ { "type": "initial", diff --git a/apps/client/server.ts b/apps/client/server.ts index 1609d2e..f3a61cb 100644 --- a/apps/client/server.ts +++ b/apps/client/server.ts @@ -40,7 +40,10 @@ export function app(): express.Express { documentFilePath: indexHtml, url: `${protocol}://${headers.host}${originalUrl}`, publicPath: distFolder, - providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], + providers: [ + { provide: APP_BASE_HREF, useValue: baseUrl }, + { provide: 'API_URL', useValue: process.env.API_URL } + ], }) .then((html) => res.send(html)) .catch((err) => next(err)); diff --git a/apps/client/src/app/shared/api-client.service.ts b/apps/client/src/app/shared/api-client.service.ts index ad0531b..f68f325 100644 --- a/apps/client/src/app/shared/api-client.service.ts +++ b/apps/client/src/app/shared/api-client.service.ts @@ -22,6 +22,8 @@ export class ApiClientService { // Auth endpoints login(loginData: LoginRequestDto): Observable { + console.log(`Making login request to: ${this.baseUrl}/auth/login`); + return this.http.post(`${this.baseUrl}/auth/login`, loginData); } diff --git a/apps/client/src/environments/environment.prod.ts b/apps/client/src/environments/environment.prod.ts index e8cbfe7..d6cf459 100644 --- a/apps/client/src/environments/environment.prod.ts +++ b/apps/client/src/environments/environment.prod.ts @@ -1,4 +1,4 @@ export const environment = { production: true, - apiUrl: '/api/v1' + apiUrl: typeof window !== 'undefined' ? window.location.origin + '/api/v1' : '${API_URL}/api/v1' }; diff --git a/apps/server/src/shared/origins.ts b/apps/server/src/shared/origins.ts index 68b7b8b..234b5d8 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", + "http://localhost:3000", ]