diff --git a/src/lib/index.ts b/src/lib/index.ts index bffbee6..9e826a2 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1,5 +1,5 @@ import type { Cookies } from '@sveltejs/kit' -import { WEBSITE_DATA_DIR } from '$env/static/private' +import { env } from '$env/dynamic/private' import { existsSync, readFileSync } from 'fs' import { writable } from 'svelte/store' @@ -17,5 +17,5 @@ export const scopeCookies = (cookies: Cookies, path: string) => { } } -export const visitCountFile = `${WEBSITE_DATA_DIR}/visitcount` +export const visitCountFile = `${env.WEBSITE_DATA_DIR}/visitcount` export const visitCount = writable(parseInt(existsSync(visitCountFile) ? readFileSync(visitCountFile).toString() : '0')); \ No newline at end of file diff --git a/src/routes/guestbook/+page.server.ts b/src/routes/guestbook/+page.server.ts index afb2eaf..5efce40 100644 --- a/src/routes/guestbook/+page.server.ts +++ b/src/routes/guestbook/+page.server.ts @@ -1,4 +1,4 @@ -import { GUESTBOOK_BASE_URL } from '$env/static/private' +import { env } from '$env/dynamic/private' import { redirect, type Cookies } from '@sveltejs/kit' import auth from '$lib/guestbookAuth' import { scopeCookies as _scopeCookies } from '$lib'; @@ -90,7 +90,7 @@ export async function load({ url, fetch, cookies }) { } // set content, make sure to trim it postData.set('content', content.substring(0, 512).trim()) - respRaw = await fetch(GUESTBOOK_BASE_URL, { method: 'POST', body: postData }) + respRaw = await fetch(env.GUESTBOOK_BASE_URL, { method: 'POST', body: postData }) } catch (err: any) { scopedCookies.set("sendError", `${err.toString()} (is guestbook server running?)`) redirect(303, auth.callbackUrl) @@ -111,7 +111,7 @@ export async function load({ url, fetch, cookies }) { try { const count = 5 const offset = (data.page - 1) * count - respRaw = await fetch(`${GUESTBOOK_BASE_URL}?offset=${offset}&count=${count}`) + respRaw = await fetch(`${env.GUESTBOOK_BASE_URL}?offset=${offset}&count=${count}`) } catch (err: any) { data.getError = `${err.toString()} (is guestbook server running?)` return data