mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Put API prefix in server only file to access process.env
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { Actions, PageServerLoad } from "./$types";
|
||||
import { API_BASE_PREFIX } from "$lib/utils";
|
||||
import { API_BASE_PREFIX } from "$lib/server/utils";
|
||||
|
||||
export const load: PageServerLoad = async ({ parent, params, cookies, fetch }) => {
|
||||
const articleData = await fetch(`${API_BASE_PREFIX}/article?id=eq.${params.articleId}`, {
|
||||
@@ -14,7 +14,7 @@ export const load: PageServerLoad = async ({ parent, params, cookies, fetch }) =
|
||||
const article = await articleData.json();
|
||||
const { website } = await parent();
|
||||
|
||||
return { website, article };
|
||||
return { website, article, API_BASE_PREFIX };
|
||||
};
|
||||
|
||||
export const actions: Actions = {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
|
||||
import type { ActionData, PageServerData } from "./$types";
|
||||
import Modal from "$lib/components/Modal.svelte";
|
||||
import { API_BASE_PREFIX, handleImagePaste } from "$lib/utils";
|
||||
import { handleImagePaste } from "$lib/utils";
|
||||
|
||||
const { data, form } = $props<{ data: PageServerData; form: ActionData }>();
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
};
|
||||
|
||||
const handlePaste = async (event: ClipboardEvent) => {
|
||||
const newContent = await handleImagePaste(event);
|
||||
const newContent = await handleImagePaste(event, data.API_BASE_PREFIX);
|
||||
previewContent = newContent;
|
||||
};
|
||||
</script>
|
||||
@@ -86,7 +86,7 @@
|
||||
{#if data.article.cover_image}
|
||||
<Modal id="preview-cover-article-{data.article.id}" text="Preview">
|
||||
<img
|
||||
src={`${API_BASE_PREFIX}/rpc/retrieve_file?id=${data.article.cover_image}`}
|
||||
src={`${data.API_BASE_PREFIX}/rpc/retrieve_file?id=${data.article.cover_image}`}
|
||||
alt=""
|
||||
/>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user