From 1ca28ec5a12673c2bbfd986e9613b7a2e5214c07 Mon Sep 17 00:00:00 2001 From: Dovile Date: Mon, 18 Mar 2024 17:12:06 +0100 Subject: [PATCH 01/10] sukeisti adresai --- .env.example | 2 +- .github/workflows/ci.yml | 4 ++-- .github/workflows/deploy-development.yml | 2 +- .github/workflows/deploy-staging.yml | 2 +- src/utils/texts.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 6e440d1..3d2a46a 100644 --- a/.env.example +++ b/.env.example @@ -1 +1 @@ -VITE_PROXY_URL=https://dev.internalapi.biip.lt/zuvinimasnew/api \ No newline at end of file +VITE_PROXY_URL=https://internalapi.biip.lt/zuvinimasnew/api diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a196905..d4bb0a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,8 +29,8 @@ jobs: run: yarn run build --mode development env: NODE_ENV: development - VITE_MAPS_HOST: https://dev.maps.biip.lt - VITE_ZUVINIMAS_API_BASE_URL: https://dev.zuvinimas.biip.lt/api + VITE_MAPS_HOST: https://dev-maps.biip.lt + VITE_ZUVINIMAS_API_BASE_URL: https://dev-zuvinimas.biip.lt/api - uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/deploy-development.yml b/.github/workflows/deploy-development.yml index 58e472a..1cfb6fe 100644 --- a/.github/workflows/deploy-development.yml +++ b/.github/workflows/deploy-development.yml @@ -18,4 +18,4 @@ jobs: build-args: | NODE_ENV=development VITE_SENTRY_DSN=https://0385edf7f78f4ad4a511abae516ae3e8@sentry.biip.lt/7 - VITE_MAPS_HOST=https://dev.maps.biip.lt + VITE_MAPS_HOST=https://dev-maps.biip.lt diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 1c47175..99cd4c4 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -19,4 +19,4 @@ jobs: build-args: | NODE_ENV=production VITE_SENTRY_DSN=https://0385edf7f78f4ad4a511abae516ae3e8@sentry.biip.lt/7 - VITE_MAPS_HOST=https://staging.maps.biip.lt + VITE_MAPS_HOST=https://staging-maps.biip.lt diff --git a/src/utils/texts.ts b/src/utils/texts.ts index 29f3d12..449e734 100644 --- a/src/utils/texts.ts +++ b/src/utils/texts.ts @@ -127,7 +127,7 @@ export const toasts = { profileUpdated: 'Profilis atnaujintas', }; -const mapsHost = import.meta.env.VITE_MAPS_HOST || 'https://dev.maps.biip.lt'; +const mapsHost = import.meta.env.VITE_MAPS_HOST || 'https://dev-maps.biip.lt'; export const Url = { DRAW: `${mapsHost}/zuvinimas/draw`, FISH_STOCKING: `${mapsHost}/zuvinimas`, From da6c0fb70563e502c3a310354607f0d80cf73be1 Mon Sep 17 00:00:00 2001 From: Dovile Date: Mon, 25 Mar 2024 23:03:29 +0200 Subject: [PATCH 02/10] fix --- .env.example | 9 ++++++++- Dockerfile | 6 ++++-- src/utils/texts.ts | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 3d2a46a..2b612af 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,8 @@ -VITE_PROXY_URL=https://internalapi.biip.lt/zuvinimasnew/api +VITE_PROXY_URL=https://zuvinimasnew.biip.lt/api +VITE_MAPS_HOST=https://maps.biip.lt +VITE_ZUVINIMAS_API_BASE_URL=/api +VITE_SENTRY_DSN= +VITE_ENVIRONMENT= +VITE_ENVIRONMENT= + + diff --git a/Dockerfile b/Dockerfile index b7ba8c2..6063428 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,9 +17,11 @@ ARG VITE_ENVIRONMENT=${ENVIRONMENT} ARG VITE_VERSION=${VERSION} # Set env variables -ARG VITE_MAPS_HOST= -ARG VITE_SENTRY_DSN= ARG NODE_ENV=production +ARG VITE_SENTRY_DSN= +ARG VITE_MAPS_HOST= +ARG VITE_ZUVINIMAS_API_BASE_URL= + # Build and cleanup RUN yarn build diff --git a/src/utils/texts.ts b/src/utils/texts.ts index 449e734..faab3e7 100644 --- a/src/utils/texts.ts +++ b/src/utils/texts.ts @@ -127,7 +127,7 @@ export const toasts = { profileUpdated: 'Profilis atnaujintas', }; -const mapsHost = import.meta.env.VITE_MAPS_HOST || 'https://dev-maps.biip.lt'; +const mapsHost = import.meta.env.VITE_MAPS_HOST; export const Url = { DRAW: `${mapsHost}/zuvinimas/draw`, FISH_STOCKING: `${mapsHost}/zuvinimas`, From acc0d40e52aa625a139733c0bfa84b8339910b52 Mon Sep 17 00:00:00 2001 From: Dovile Date: Mon, 25 Mar 2024 23:24:22 +0200 Subject: [PATCH 03/10] fix --- .env.example | 3 +-- Dockerfile | 1 - src/utils/api.ts | 8 +++----- vite.config.mts | 7 +++++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.env.example b/.env.example index 2b612af..0289999 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,5 @@ -VITE_PROXY_URL=https://zuvinimasnew.biip.lt/api +VITE_PROXY_URL=https://zuvinimasnew.biip.lt VITE_MAPS_HOST=https://maps.biip.lt -VITE_ZUVINIMAS_API_BASE_URL=/api VITE_SENTRY_DSN= VITE_ENVIRONMENT= VITE_ENVIRONMENT= diff --git a/Dockerfile b/Dockerfile index 6063428..4bf26bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,6 @@ ARG VITE_VERSION=${VERSION} ARG NODE_ENV=production ARG VITE_SENTRY_DSN= ARG VITE_MAPS_HOST= -ARG VITE_ZUVINIMAS_API_BASE_URL= # Build and cleanup diff --git a/src/utils/api.ts b/src/utils/api.ts index 7a612b1..77b1dd5 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -79,11 +79,9 @@ interface Create { class Api { private AuthApiAxios: AxiosInstance; - private readonly apiBaseUrl: string; + private readonly proxy: string = '/proxy'; constructor() { - this.apiBaseUrl = env.VITE_ZUVINIMAS_API_BASE_URL ?? '/api'; - this.AuthApiAxios = Axios.create(); this.AuthApiAxios.interceptors.request.use( (config) => { @@ -93,7 +91,7 @@ class Api { config.headers!.Authorization = 'Bearer ' + token; if (isFinite(parseInt(profileId))) config.headers!['X-Profile'] = profileId; } - config.url = this.apiBaseUrl + config.url; + config.url = this.proxy + config.url; return config; }, (error) => { @@ -418,7 +416,7 @@ class Api { const profileId = cookies.get('profileId'); const response = await fetch( - `${this.apiBaseUrl}/${Resources.EXCEL}?filter=${JSON.stringify(filter)}`, + `${this.proxy}/${Resources.EXCEL}?filter=${JSON.stringify(filter)}`, { headers: { 'Content-Type': 'application/json', diff --git a/vite.config.mts b/vite.config.mts index 401df9d..8ce7d20 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -10,10 +10,13 @@ export default () => { plugins: [react(), VitePWA(manifestForPlugIn as Partial)], server: { proxy: { - '/api': { + '/proxy': { target: env.VITE_PROXY_URL, changeOrigin: true, - rewrite: (path) => path.replace(/^\/api/, ''), + rewrite: (path) => { + console.log('path', path, path.replace(/^\/proxy/, '')) + return path.replace(/^\/proxy/, '') + }, }, }, }, From d7d8080eaae1e710caae99e63b12aaaf6de3be07 Mon Sep 17 00:00:00 2001 From: Dovile Date: Mon, 25 Mar 2024 23:31:04 +0200 Subject: [PATCH 04/10] Revert "fix" This reverts commit acc0d40e52aa625a139733c0bfa84b8339910b52. --- .env.example | 3 ++- Dockerfile | 1 + src/utils/api.ts | 8 +++++--- vite.config.mts | 7 ++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 0289999..2b612af 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,6 @@ -VITE_PROXY_URL=https://zuvinimasnew.biip.lt +VITE_PROXY_URL=https://zuvinimasnew.biip.lt/api VITE_MAPS_HOST=https://maps.biip.lt +VITE_ZUVINIMAS_API_BASE_URL=/api VITE_SENTRY_DSN= VITE_ENVIRONMENT= VITE_ENVIRONMENT= diff --git a/Dockerfile b/Dockerfile index 4bf26bc..6063428 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ ARG VITE_VERSION=${VERSION} ARG NODE_ENV=production ARG VITE_SENTRY_DSN= ARG VITE_MAPS_HOST= +ARG VITE_ZUVINIMAS_API_BASE_URL= # Build and cleanup diff --git a/src/utils/api.ts b/src/utils/api.ts index 77b1dd5..7a612b1 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -79,9 +79,11 @@ interface Create { class Api { private AuthApiAxios: AxiosInstance; - private readonly proxy: string = '/proxy'; + private readonly apiBaseUrl: string; constructor() { + this.apiBaseUrl = env.VITE_ZUVINIMAS_API_BASE_URL ?? '/api'; + this.AuthApiAxios = Axios.create(); this.AuthApiAxios.interceptors.request.use( (config) => { @@ -91,7 +93,7 @@ class Api { config.headers!.Authorization = 'Bearer ' + token; if (isFinite(parseInt(profileId))) config.headers!['X-Profile'] = profileId; } - config.url = this.proxy + config.url; + config.url = this.apiBaseUrl + config.url; return config; }, (error) => { @@ -416,7 +418,7 @@ class Api { const profileId = cookies.get('profileId'); const response = await fetch( - `${this.proxy}/${Resources.EXCEL}?filter=${JSON.stringify(filter)}`, + `${this.apiBaseUrl}/${Resources.EXCEL}?filter=${JSON.stringify(filter)}`, { headers: { 'Content-Type': 'application/json', diff --git a/vite.config.mts b/vite.config.mts index 8ce7d20..401df9d 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -10,13 +10,10 @@ export default () => { plugins: [react(), VitePWA(manifestForPlugIn as Partial)], server: { proxy: { - '/proxy': { + '/api': { target: env.VITE_PROXY_URL, changeOrigin: true, - rewrite: (path) => { - console.log('path', path, path.replace(/^\/proxy/, '')) - return path.replace(/^\/proxy/, '') - }, + rewrite: (path) => path.replace(/^\/api/, ''), }, }, }, From e83eda31c0bd6454cec71476cc856695970d5ec7 Mon Sep 17 00:00:00 2001 From: Dovile Date: Tue, 26 Mar 2024 13:57:23 +0200 Subject: [PATCH 05/10] fix --- Dockerfile | 1 - src/utils/api.ts | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6063428..4bf26bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,6 @@ ARG VITE_VERSION=${VERSION} ARG NODE_ENV=production ARG VITE_SENTRY_DSN= ARG VITE_MAPS_HOST= -ARG VITE_ZUVINIMAS_API_BASE_URL= # Build and cleanup diff --git a/src/utils/api.ts b/src/utils/api.ts index 7a612b1..5decea8 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -7,7 +7,6 @@ import Cookies from 'universal-cookie'; import { Resources } from './constants'; const cookies = new Cookies(); -const env = import.meta.env; interface GetAll { resource?: string; @@ -79,11 +78,9 @@ interface Create { class Api { private AuthApiAxios: AxiosInstance; - private readonly apiBaseUrl: string; + private readonly proxy: string = '/api'; constructor() { - this.apiBaseUrl = env.VITE_ZUVINIMAS_API_BASE_URL ?? '/api'; - this.AuthApiAxios = Axios.create(); this.AuthApiAxios.interceptors.request.use( (config) => { @@ -93,7 +90,7 @@ class Api { config.headers!.Authorization = 'Bearer ' + token; if (isFinite(parseInt(profileId))) config.headers!['X-Profile'] = profileId; } - config.url = this.apiBaseUrl + config.url; + config.url = this.proxy + config.url; return config; }, (error) => { @@ -231,6 +228,15 @@ class Api { pageSize: '12', }); + // getFishStockings = async ({ filter, page }: TableList): Promise> => + // await this.get({ + // resource: Resources.FISH_STOCKING, + // populate: ['batches', 'createdBy', 'reviewedBy', 'assignedTo', 'status', 'location'], + // filter, + // page, + // pageSize: '12', + // }); + createTenantUser = async (params: any): Promise => { return await this.create({ resource: Resources.INVITE_USER, @@ -418,7 +424,7 @@ class Api { const profileId = cookies.get('profileId'); const response = await fetch( - `${this.apiBaseUrl}/${Resources.EXCEL}?filter=${JSON.stringify(filter)}`, + `${this.proxy}/${Resources.EXCEL}?filter=${JSON.stringify(filter)}`, { headers: { 'Content-Type': 'application/json', From c2c37083f24bf328aa3a999ec1b33f01ebf0c358 Mon Sep 17 00:00:00 2001 From: Dovile Date: Tue, 26 Mar 2024 13:59:03 +0200 Subject: [PATCH 06/10] fix --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 2b612af..565cac1 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -VITE_PROXY_URL=https://zuvinimasnew.biip.lt/api +VITE_PROXY_URL=https://zuvinimas.biip.lt/api VITE_MAPS_HOST=https://maps.biip.lt VITE_ZUVINIMAS_API_BASE_URL=/api VITE_SENTRY_DSN= From 1f54a4895eafad2db25301d127b6ff23c0c7bd91 Mon Sep 17 00:00:00 2001 From: Dovile Date: Tue, 26 Mar 2024 14:00:01 +0200 Subject: [PATCH 07/10] delete comment --- src/utils/api.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/utils/api.ts b/src/utils/api.ts index 5decea8..3b1494b 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -228,15 +228,6 @@ class Api { pageSize: '12', }); - // getFishStockings = async ({ filter, page }: TableList): Promise> => - // await this.get({ - // resource: Resources.FISH_STOCKING, - // populate: ['batches', 'createdBy', 'reviewedBy', 'assignedTo', 'status', 'location'], - // filter, - // page, - // pageSize: '12', - // }); - createTenantUser = async (params: any): Promise => { return await this.create({ resource: Resources.INVITE_USER, From 3784a6e8c851d070718484b868ba64447aa3a3ca Mon Sep 17 00:00:00 2001 From: Dovile Date: Tue, 26 Mar 2024 14:00:34 +0200 Subject: [PATCH 08/10] delete duplicate --- .env.example | 1 - 1 file changed, 1 deletion(-) diff --git a/.env.example b/.env.example index 565cac1..0455237 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,5 @@ VITE_MAPS_HOST=https://maps.biip.lt VITE_ZUVINIMAS_API_BASE_URL=/api VITE_SENTRY_DSN= VITE_ENVIRONMENT= -VITE_ENVIRONMENT= From be6e1e74210a9ef65efba158d2a93842b4a35195 Mon Sep 17 00:00:00 2001 From: Dovile Date: Tue, 26 Mar 2024 14:02:32 +0200 Subject: [PATCH 09/10] delete unused arg --- .env.example | 1 - .github/workflows/ci.yml | 1 - src/vite-env.d.ts | 1 - 3 files changed, 3 deletions(-) diff --git a/.env.example b/.env.example index 0455237..384f1e6 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,5 @@ VITE_PROXY_URL=https://zuvinimas.biip.lt/api VITE_MAPS_HOST=https://maps.biip.lt -VITE_ZUVINIMAS_API_BASE_URL=/api VITE_SENTRY_DSN= VITE_ENVIRONMENT= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4bb0a9..edf64ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,6 @@ jobs: env: NODE_ENV: development VITE_MAPS_HOST: https://dev-maps.biip.lt - VITE_ZUVINIMAS_API_BASE_URL: https://dev-zuvinimas.biip.lt/api - uses: actions/upload-artifact@v4 with: diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index f38a662..87cf008 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -2,7 +2,6 @@ interface ImportMetaEnv { readonly NODE_ENV: 'development' | 'production'; - readonly VITE_ZUVINIMAS_API_BASE_URL?: string; readonly VITE_SENTRY_DSN?: string; readonly VITE_ENVIRONMENT?: string; readonly VITE_MAPS_HOST?: string; From 52b44b1e11f11cb00e86bea902cfd1eb328b4427 Mon Sep 17 00:00:00 2001 From: Dovile Date: Tue, 26 Mar 2024 14:04:43 +0200 Subject: [PATCH 10/10] delete unused arg --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edf64ad..2b811af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,6 @@ jobs: run: yarn run build --mode development env: NODE_ENV: development - VITE_MAPS_HOST: https://dev-maps.biip.lt - uses: actions/upload-artifact@v4 with: