π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Moving to runtimeConfig to resolve env variables at runtime
Smaug6739a2240fc63a1c
diff --git a/.github/workflows/deploy_to_prod.yml b/.github/workflows/deploy_to_prod.ymlindex bbc3dd1f..e4067857 100755--- a/.github/workflows/deploy_to_prod.yml+++ b/.github/workflows/deploy_to_prod.yml@@ -53,9 +53,9 @@ jobs:DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}# -------------------------- # Generate .env file with secrets+ # Generate .env file with secrets & configuration# -------------------------- - name: Create .env.production for backend+ - name: Create .env.production for applicationrun: |cat > .env.production <<EOFNODE_ENV=production@@ -67,6 +67,8 @@ jobs:SMTP_HOST=${{ secrets.SMTP_HOST }}SMTP_MAIL=${{ secrets.SMTP_MAIL }}SMTP_PASSWORD=${{ secrets.SMTP_PASSWORD }}+ NUXT_PUBLIC_BASE_API=https://api.alexandrie-hub.fr+ NUXT_PUBLIC_BASE_CDN=https://cdn.alexandrie-hub.frEOF# -------------------------diff --git a/docker-compose.yml b/docker-compose.ymlindex e5be07d6..53a8a991 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -94,8 +94,8 @@ services:environment:PORT: 8200# Runtime configuration - builds with these values at startup- VITE_BASE_API: http://localhost:8201- VITE_BASE_CDN: http://localhost:9000/alexandrie+ NUXT_PUBLIC_BASE_API: http://localhost:8201+ NUXT_PUBLIC_BASE_CDN: http://localhost:9000/alexandrieNUXT_PUBLIC_BASE_URL: http://localhost:8200ports:- '8200:8200'diff --git a/frontend/.env b/frontend/.envnew file mode 100644index 00000000..4466d368--- /dev/null+++ b/frontend/.env@@ -0,0 +1,2 @@+NUXT_PUBLIC_BASE_API=http://localhost:8201+NUXT_PUBLIC_BASE_CDN=http://localhost:9000/alexandrie\ No newline at end of filediff --git a/frontend/app/.env.development b/frontend/app/.env.developmentdeleted file mode 100644index 30dc16bf..00000000--- a/frontend/app/.env.development+++ /dev/null@@ -1,2 +0,0 @@-VITE_BASE_API="http://localhost:8201"-VITE_BASE_CDN="http://localhost:9000/alexandrie"\ No newline at end of filediff --git a/frontend/app/.env.production b/frontend/app/.env.productiondeleted file mode 100644index a11ac8ed..00000000--- a/frontend/app/.env.production+++ /dev/null@@ -1,2 +0,0 @@-VITE_BASE_API="https://api.alexandrie-hub.fr"-VITE_BASE_CDN="https://cdn.alexandrie-hub.fr"\ No newline at end of filediff --git a/frontend/app/composables/utils.ts b/frontend/app/composables/utils.tsindex 265e26cb..e66398f6 100644--- a/frontend/app/composables/utils.ts+++ b/frontend/app/composables/utils.ts@@ -1,14 +1,18 @@import type { PublicUser, User } from '~/stores/db_strustures';-export const CDN = import.meta.env.VITE_BASE_CDN;-export const API = `${import.meta.env.VITE_BASE_API}/api`;-+export function useApi() {+ const config = useRuntimeConfig();+ const CDN = config.public.baseCdn;+ const API = `${config.public.baseApi}/api`;+ return { CDN, API };+}// Little screen sizeexport const isMobile = () => (import.meta.client ? window.innerWidth <= 768 : false);// Intermediate screen sizeexport const isTablet = () => (import.meta.client ? window.innerWidth <= 1280 : false);export function useAvatar(user?: User | PublicUser | null): string {+ const { CDN } = useApi();return user?.avatar ? CDN + '/' + user.id + '/avatar' : '/default_avatar.avif';}diff --git a/frontend/app/pages/dashboard/settings/_views/backups.vue b/frontend/app/pages/dashboard/settings/_views/backups.vueindex c5f14a15..ecd40e2c 100644--- a/frontend/app/pages/dashboard/settings/_views/backups.vue+++ b/frontend/app/pages/dashboard/settings/_views/backups.vue@@ -29,6 +29,7 @@ const downloadLink = ref<string | null>(null);const copyLink = () => navigator.clipboard.writeText(downloadLink.value!);const isLoading = ref(false);const fileName = () => `backup-${new Date().toISOString().split('T')[0]}.json`;+const { CDN } = useApi();async function submitFile() {isLoading.value = true;const result = await makeRequest<{ link: string }>('ressources/backup', 'GET', {});diff --git a/frontend/app/stores/_utils.ts b/frontend/app/stores/_utils.tsindex 0beb83db..57a9e4ab 100644--- a/frontend/app/stores/_utils.ts+++ b/frontend/app/stores/_utils.ts@@ -10,7 +10,13 @@ export interface FetchOptions {let is_getting_new_token = false;// eslint-disable-next-line @typescript-eslint/no-explicit-any-const requestQueue: { route: string; method: string; body: object; resolve: (value: APIResult<any> | PromiseLike<APIResult<any>>) => void; reject: (reason?: object) => void }[] = [];+const requestQueue: {+ route: string;+ method: string;+ body: object;+ resolve: (value: APIResult<any> | PromiseLike<APIResult<any>>) => void;+ reject: (reason?: object) => void;+}[] = [];export async function makeRequest<T>(route: string, method: string, body: object, isTreatingQueue: boolean = false): Promise<APIResult<T>> {console.log(`[API] Requesting [${method}] to /${route}`);@@ -62,6 +68,7 @@ function treatQueue(access_token: boolean = true) {}function customFetch(method: string, route: string, body: object) {+ const { API } = useApi();return fetch(`${API}/${route}`, {method: method,body: method === 'GET' || method === 'DELETE' ? null : body instanceof FormData ? body : JSON.stringify(body),diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.tsindex 8a79f14f..3c92643e 100644--- a/frontend/nuxt.config.ts+++ b/frontend/nuxt.config.ts@@ -4,7 +4,12 @@ import { defineNuxtConfig } from 'nuxt/config';export default defineNuxtConfig({devtools: { enabled: process.env.NODE_ENV !== 'production' },-+ runtimeConfig: {+ public: {+ baseApi: '',+ baseCdn: '',+ },+ },vite: {css: {preprocessorOptions: {