diff --git a/Containerfile b/Containerfile index 1389b0f..1f814b7 100644 --- a/Containerfile +++ b/Containerfile @@ -11,9 +11,7 @@ RUN npm ci COPY . . -RUN echo "CONTAINER DEBUG: WEBMENTION_TOKEN length=${#WEBMENTION_TOKEN}" - -RUN node -e "console.log('NODE sees WEBMENTION_TOKEN length:', (process.env.WEBMENTION_TOKEN || '').length)" +RUN printf '%s' "${WEBMENTION_TOKEN}" > /app/.webmention-token RUN npm run build diff --git a/astro.config.mjs b/astro.config.mjs index 25fb9a9..d0c8b4b 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -2,7 +2,7 @@ import mdx from '@astrojs/mdx'; import sitemap from '@astrojs/sitemap'; -import { defineConfig, envField, fontProviders } from 'astro/config'; +import { defineConfig, fontProviders } from 'astro/config'; import node from '@astrojs/node'; @@ -10,16 +10,6 @@ import node from '@astrojs/node'; export default defineConfig({ site: 'https://adrian-altner.de', - env: { - schema: { - WEBMENTION_TOKEN: envField.string({ - context: 'server', - access: 'secret', - optional: true, - }), - }, - }, - devToolbar: { enabled: false, }, diff --git a/src/components/Webmentions.astro b/src/components/Webmentions.astro index cf3c08a..eb4dcde 100644 --- a/src/components/Webmentions.astro +++ b/src/components/Webmentions.astro @@ -1,8 +1,24 @@ --- -import { WEBMENTION_TOKEN } from 'astro:env/server'; +import { readFileSync } from 'node:fs'; import { DEFAULT_LOCALE, type Locale } from '~/consts'; import { getLocaleFromUrl, t } from '~/i18n/ui'; +function readTokenFromFile(): string | undefined { + const paths = ['/app/.webmention-token', '.webmention-token']; + for (const p of paths) { + try { + const raw = readFileSync(p, 'utf-8').trim(); + if (raw) return raw; + } catch { + // file not present, try next + } + } + return undefined; +} + +const FILE_TOKEN = readTokenFromFile(); +const WEBMENTION_TOKEN = FILE_TOKEN ?? (import.meta.env as Record).WEBMENTION_TOKEN; + interface WMAuthor { name?: string; url?: string;