From 270677024480504cc9b0929863fa062b5f983b3a Mon Sep 17 00:00:00 2001 From: Nathaniel Blackburn Date: Thu, 5 Dec 2024 22:12:03 +0000 Subject: [PATCH] refactor: replace env with astro:env --- astro.config.mjs | 20 +++++++++++--------- src/components/turnStile.vue | 3 ++- src/pages/api/contact.ts | 5 +++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 16112773..43596af5 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,7 +1,7 @@ import vue from '@astrojs/vue'; -import sitemap from '@astrojs/sitemap'; -import { defineConfig } from 'astro/config'; import vercel from '@astrojs/vercel'; +import sitemap from '@astrojs/sitemap'; +import { defineConfig, envField } from 'astro/config'; import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; export default defineConfig({ @@ -19,13 +19,15 @@ export default defineConfig({ } }), - vite: { - plugins: [vanillaExtractPlugin()], - - define: { - 'import.meta.env.PUBLIC_VERCEL_ANALYTICS_ID': JSON.stringify( - process.env.VERCEL_ANALYTICS_ID - ) + env: { + schema: { + RESEND_API_KEY: envField({ context: 'server', access: 'secret' }), + TURNSTILE_SITE_KEY: envField({ context: 'client', access: 'public' }), + TURNSTILE_SECRET_KEY: envField({ context: 'server', access: 'secret' }) } + }, + + vite: { + plugins: [vanillaExtractPlugin()] } }); diff --git a/src/components/turnStile.vue b/src/components/turnStile.vue index a01d044c..99adb471 100644 --- a/src/components/turnStile.vue +++ b/src/components/turnStile.vue @@ -4,13 +4,14 @@