From facb07de5bcf803b73f9719281a22d4d8f5629e9 Mon Sep 17 00:00:00 2001 From: Pascal Syma Date: Sat, 2 Aug 2025 01:18:37 +0200 Subject: [PATCH] Add s3 endpoint as preload --- .env.example | 4 ++-- app/app.vue | 4 ++++ index.d.ts | 6 ++++-- lib/s3.ts | 7 +++++-- nuxt.config.ts | 6 ++++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index f9060fc..66f2326 100644 --- a/.env.example +++ b/.env.example @@ -11,7 +11,7 @@ REDIS_PORT=6379 NUXT_REDIS_HOST=redis NUXT_REDIS_PASSWORD=# openssl rand -base64 32 -NUXT_S3_BUCKET=pichunt -NUXT_S3_HOST=s3.swarm.syma.dev +NUXT_PUBLIC_S3_BUCKET=pichunt +NUXT_PUBLIC_S3_HOST=s3.swarm.syma.dev NUXT_S3_ACCESS_KEY=access_key NUXT_S3_SECRET_KEY=secret_key \ No newline at end of file diff --git a/app/app.vue b/app/app.vue index 95b2df9..0ca68a4 100644 --- a/app/app.vue +++ b/app/app.vue @@ -12,6 +12,8 @@ const title = computed(() => title: t((route.meta.title as string) || 'layouts.default_tile') }) ); + +const { s3Bucket, s3Host } = useRuntimeConfig().public; + + diff --git a/index.d.ts b/index.d.ts index a05b61f..1e54e89 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,10 +1,12 @@ declare module 'nuxt/schema' { interface RuntimeConfig { - s3Bucket: string; - s3Host: string; s3AccessKey: string; s3SecretKey: string; } + interface PublicRuntimeConfig { + s3Bucket: string; + s3Host: string; + } } // It is always important to ensure you import/export something when augmenting a type export {}; diff --git a/lib/s3.ts b/lib/s3.ts index 3582e9f..0dcbc97 100644 --- a/lib/s3.ts +++ b/lib/s3.ts @@ -2,8 +2,11 @@ import { Client } from 'minio'; // TODO: add docker secret parsing -export const { s3Bucket, s3Host, s3AccessKey, s3SecretKey } = - useRuntimeConfig(); +export const { + public: { s3Bucket, s3Host }, + s3AccessKey, + s3SecretKey +} = useRuntimeConfig(); export const minioClient = new Client({ endPoint: s3Host, diff --git a/nuxt.config.ts b/nuxt.config.ts index 4e32c22..5bb6d04 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -12,8 +12,10 @@ export default defineNuxtConfig({ '@pinia/nuxt' ], runtimeConfig: { - s3Bucket: 'pichunt', - s3Host: 's3.swarm.syma.dev', + public: { + s3Bucket: 'pichunt', + s3Host: 's3.swarm.syma.dev' + }, s3AccessKey: 'user', s3SecretKey: 'password' },