From 3d1e1aeb82e52d6027dc64a59129b63eadb4f2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Tue, 19 Mar 2024 10:02:05 +0100 Subject: [PATCH 1/2] fix: fixed production envs --- plugins/axios.ts | 5 +++-- plugins/vue-gtag.client.ts | 5 +++-- server/routes/robots.txt.get.ts | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/axios.ts b/plugins/axios.ts index 231a8353..f1dd43c2 100644 --- a/plugins/axios.ts +++ b/plugins/axios.ts @@ -19,7 +19,8 @@ declare module 'axios' { const cacheStorage = buildMemoryStorage() export default defineNuxtPlugin((nuxt) => { - const { apiUrl: baseURL, isProduction, axiosCacheTtl } = usePublicRuntimeConfig() + const { apiUrl: baseURL, production, axiosCacheTtl } = usePublicRuntimeConfig() + const isProduction = computed(() => ['true', '1', 1, true].includes(production)) const axiosCacheTtlTime = parseInt(axiosCacheTtl || '0') ?? 0 const localePath = useLocalePath() @@ -113,7 +114,7 @@ export default defineNuxtPlugin((nuxt) => { ax.interceptors.response.use((response) => { const config = response.config config._endTime = Date.now() - if (!isProduction) { + if (!isProduction.value) { const time = response.cached ? 'cache' : `${config._endTime - config._beginTime!}ms` // eslint-disable-next-line no-console console.log(`(${time}) - [${config.method}] ${config.url}`) diff --git a/plugins/vue-gtag.client.ts b/plugins/vue-gtag.client.ts index 11d1dae2..2c1ebce5 100644 --- a/plugins/vue-gtag.client.ts +++ b/plugins/vue-gtag.client.ts @@ -13,14 +13,15 @@ import { mapCartItemToItem, mapOrderProductToItem, mapProductToItem } from '@/ut import { useChannelsStore } from '@/store/channels' export default defineNuxtPlugin((nuxtApp) => { - const { googleTagManagerId, isProduction, i18n } = usePublicRuntimeConfig() + const { googleTagManagerId, production, i18n } = usePublicRuntimeConfig() + const isProduction = computed(() => ['true', '1', 1, true].includes(production)) if (!googleTagManagerId) return nuxtApp.vueApp.use( createGtm({ id: googleTagManagerId, defer: true, - debug: !isProduction, + debug: !isProduction.value, vueRouter: useRouter(), loadScript: true, enabled: false, diff --git a/server/routes/robots.txt.get.ts b/server/routes/robots.txt.get.ts index a985c807..eac375fa 100644 --- a/server/routes/robots.txt.get.ts +++ b/server/routes/robots.txt.get.ts @@ -22,8 +22,9 @@ Disallow: / export default defineEventHandler((event) => { // @ts-ignore Docs suggest to pass event to useRuntimeConfig, but it's not typed? https://nuxt.com/docs/guide/going-further/runtime-config#server-routes const config = useRuntimeConfig(event) + const isProduction = computed(() => ['true', '1', 1, true].includes(config.public.production)) setHeader(event, 'Content-Type', 'text/plain; charset=utf-8') - return config.public.isProduction ? ALLOWED : DISALLOWED + return isProduction.value ? ALLOWED : DISALLOWED }) From b01ab791fe5347a5757a612c9709d9d042b46340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20M=C4=99dryga=C5=82?= Date: Tue, 19 Mar 2024 10:02:20 +0100 Subject: [PATCH 2/2] chore: version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e9ed30f..3c97efde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "store", - "version": "2.2.0", + "version": "2.2.1", "private": true, "scripts": { "start": "nuxt start",