diff --git a/.env.example b/.env.example index b2446e9..3a9346d 100644 --- a/.env.example +++ b/.env.example @@ -14,4 +14,6 @@ POSTGRES_PASSWORD= POSTGRES_DATABASE= # Artalk configuration +ARTALK_SCHEME= ARTALK_HOST= +ARTALK_PORT= diff --git a/astro.config.ts b/astro.config.ts index 6a75b72..07feac1 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -32,7 +32,9 @@ export default defineConfig({ POSTGRES_PASSWORD: envField.string({ context: 'server', access: 'secret' }), POSTGRES_DATABASE: envField.string({ context: 'server', access: 'secret' }), // Artalk Comment + ARTALK_SCHEME: envField.string({ context: 'server', access: 'secret' }), ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }), + ARTALK_PORT: envField.number({ context: 'server', access: 'secret' }), }, validateSecrets: true, }, diff --git a/src/components/comment/artalk.ts b/src/components/comment/artalk.ts index c42d789..f4ccb3c 100644 --- a/src/components/comment/artalk.ts +++ b/src/components/comment/artalk.ts @@ -2,7 +2,7 @@ import type { Comment, CommentItem, CommentReq, CommentResp, Comments, ErrorResp import { queryUser } from '@/helpers/db/query'; import { urlJoin } from '@/helpers/tools'; import options from '@/options'; -import { ARTALK_HOST } from 'astro:env/server'; +import { ARTALK_HOST, ARTALK_PORT, ARTALK_SCHEME } from 'astro:env/server'; import _ from 'lodash'; import { marked } from 'marked'; import querystring from 'node:querystring'; @@ -10,7 +10,7 @@ import { ELEMENT_NODE, transform, walk } from 'ultrahtml'; import sanitize from 'ultrahtml/transformers/sanitize'; // Access the artalk in internal docker host when it was deployed on zeabur. -const server = options.isProd() ? `http://${ARTALK_HOST}:23366` : `https://${ARTALK_HOST}`; +const server = `${ARTALK_SCHEME}://${ARTALK_HOST}:${ARTALK_PORT}`; export const loadComments = async (key: string, title: string | null, offset: number): Promise => { let params: Record = {