From 893c0bcd62470156d10893768eba3d3034c4dc40 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 | 13 +++++++++++++ apps/client/project.json | 6 ++++++ apps/client/server.ts | 2 ++ 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, 25 insertions(+), 2 deletions(-) diff --git a/apps/client/nginx.conf b/apps/client/nginx.conf index 7c624c9..7632e2a 100644 --- a/apps/client/nginx.conf +++ b/apps/client/nginx.conf @@ -27,6 +27,19 @@ http { location / { try_files $uri $uri/ /index.html; + add_header 'Access-Control-Allow-Origin' '$http_origin' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT' always; + add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '$http_origin' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT' always; + add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } } location ~* ^(?!/assets/).*$ { 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..562291a 100644 --- a/apps/client/server.ts +++ b/apps/client/server.ts @@ -33,6 +33,8 @@ export function app(): express.Express { // All regular routes use the Angular engine server.get('*', (req, res, next) => { const { protocol, originalUrl, baseUrl, headers } = req; + console.log(`SSR request: ${protocol}://${headers.host}${originalUrl}`); + commonEngine .render({ 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", ]