diff --git a/apps/web/config/schema/runtime-config.js b/apps/web/config/schema/runtime-config.js index bd4b562..d5dea27 100644 --- a/apps/web/config/schema/runtime-config.js +++ b/apps/web/config/schema/runtime-config.js @@ -12,7 +12,6 @@ const serverRuntimeConfigSchema = envSchema.pick({ URL_CORE_CALCULATE_DIRECT: true, URL_CORE_FINGAP_DIRECT: true, URL_CRM_CREATEKP_DIRECT: true, - URL_CRM_DOWNLOADKP_BASE: true, URL_CRM_GRAPHQL_DIRECT: true, URL_ELT_KASKO_DIRECT: true, URL_ELT_OSAGO_DIRECT: true, diff --git a/apps/web/config/urls.ts b/apps/web/config/urls.ts index 0afce80..8999d71 100644 --- a/apps/web/config/urls.ts +++ b/apps/web/config/urls.ts @@ -8,6 +8,10 @@ const { serverRuntimeConfig, publicRuntimeConfig } = getConfig(); function getUrls() { const { BASE_PATH } = publicRuntimeConfigSchema.parse(publicRuntimeConfig); + function withBasePath(url: string) { + return BASE_PATH + url; + } + if (isServer()) { const { URL_CRM_GRAPHQL_DIRECT, @@ -16,7 +20,6 @@ function getUrls() { URL_1C_TRANSTAX_DIRECT, URL_CORE_CALCULATE_DIRECT, URL_CRM_CREATEKP_DIRECT, - URL_CRM_DOWNLOADKP_BASE, PORT, URL_ELT_KASKO_DIRECT, URL_ELT_OSAGO_DIRECT, @@ -29,7 +32,7 @@ function getUrls() { URL_CORE_CALCULATE: URL_CORE_CALCULATE_DIRECT, URL_CORE_FINGAP: URL_CORE_FINGAP_DIRECT, URL_CRM_CREATEKP: URL_CRM_CREATEKP_DIRECT, - URL_CRM_DOWNLOADKP_BASE, + URL_CRM_DOWNLOADKP: withBasePath(urls.URL_CRM_DOWNLOADKP_PROXY), URL_CRM_GRAPHQL: URL_CRM_GRAPHQL_DIRECT, URL_ELT_KASKO: URL_ELT_KASKO_DIRECT, URL_ELT_OSAGO: URL_ELT_OSAGO_DIRECT, @@ -37,16 +40,13 @@ function getUrls() { }; } - function withBasePath(url: string) { - return BASE_PATH + url; - } - return { BASE_PATH, URL_1C_TRANSTAX: withBasePath(urls.URL_1C_TRANSTAX_PROXY), URL_CORE_CALCULATE: withBasePath(urls.URL_CORE_CALCULATE_PROXY), URL_CORE_FINGAP: withBasePath(urls.URL_CORE_FINGAP_PROXY), URL_CRM_CREATEKP: withBasePath(urls.URL_CRM_CREATEKP_PROXY), + URL_CRM_DOWNLOADKP: withBasePath(urls.URL_CRM_DOWNLOADKP_PROXY), URL_CRM_GRAPHQL: withBasePath(urls.URL_CRM_GRAPHQL_PROXY), URL_ELT_KASKO: withBasePath(urls.URL_ELT_KASKO_PROXY), URL_ELT_OSAGO: withBasePath(urls.URL_ELT_OSAGO_PROXY), diff --git a/apps/web/constants/urls.js b/apps/web/constants/urls.js index a8e66b4..280ac3b 100644 --- a/apps/web/constants/urls.js +++ b/apps/web/constants/urls.js @@ -3,6 +3,7 @@ module.exports = { URL_CORE_CALCULATE_PROXY: '/api/core/calculate', URL_CORE_FINGAP_PROXY: '/api/core/fingap', URL_CRM_CREATEKP_PROXY: '/api/crm/create-kp', + URL_CRM_DOWNLOADKP_PROXY: '/api/crm/download-kp', URL_CRM_GRAPHQL_PROXY: '/api/graphql/crm', URL_ELT_KASKO_PROXY: '/api/elt/kasko', URL_ELT_OSAGO_PROXY: '/api/elt/osago', diff --git a/apps/web/next.config.js b/apps/web/next.config.js index f54b9f7..4a6b56f 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -44,6 +44,10 @@ const nextConfig = { destination: env.URL_CRM_GRAPHQL_DIRECT, source: urls.URL_CRM_GRAPHQL_PROXY, }, + { + destination: env.URL_CRM_DOWNLOADKP_BASE + '/:path*', + source: urls.URL_CRM_DOWNLOADKP_PROXY + '/:path*', + }, { destination: env.URL_GET_USER_DIRECT, source: urls.URL_GET_USER_PROXY, diff --git a/apps/web/server/routers/quote/index.ts b/apps/web/server/routers/quote/index.ts index a21580b..e900b2d 100644 --- a/apps/web/server/routers/quote/index.ts +++ b/apps/web/server/routers/quote/index.ts @@ -49,7 +49,7 @@ const defaultInsurance = { const defaultFingap = { keys: [] }; const defaultPayments = { values: [], sums: [] }; -const { URL_CRM_DOWNLOADKP_BASE } = getUrls(); +const { URL_CRM_DOWNLOADKP } = getUrls(); export const quoteRouter = router({ getQuote: publicProcedure @@ -166,10 +166,8 @@ export const quoteRouter = router({ responseCalculate: calculateResult, }); - if (URL_CRM_DOWNLOADKP_BASE) { - result.values.downloadKp = URL_CRM_DOWNLOADKP_BASE?.concat( - createKPResult.offerprintformapi - ); + if (URL_CRM_DOWNLOADKP) { + result.values.downloadKp = URL_CRM_DOWNLOADKP?.concat(createKPResult.offerprintformapi); } return {