mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Differentiate between dev and prod for api and nginx
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Actions, PageServerLoad } from "./$types";
|
||||
import { API_BASE_PREFIX } from "$lib/utils";
|
||||
|
||||
export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent }) => {
|
||||
const searchQuery = url.searchParams.get("article_search_query");
|
||||
@@ -6,7 +7,7 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent
|
||||
|
||||
const parameters = new URLSearchParams();
|
||||
|
||||
const baseFetchUrl = `/api/article?website_id=eq.${params.websiteId}&select=id,title`;
|
||||
const baseFetchUrl = `${API_BASE_PREFIX}/article?website_id=eq.${params.websiteId}&select=id,title`;
|
||||
|
||||
if (searchQuery) {
|
||||
parameters.append("title", `ilike.*${searchQuery}*`);
|
||||
@@ -66,7 +67,7 @@ export const actions: Actions = {
|
||||
createArticle: async ({ request, fetch, cookies, params, locals }) => {
|
||||
const data = await request.formData();
|
||||
|
||||
const res = await fetch(`/api/article`, {
|
||||
const res = await fetch(`${API_BASE_PREFIX}/article`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -89,7 +90,7 @@ export const actions: Actions = {
|
||||
deleteArticle: async ({ request, fetch, cookies }) => {
|
||||
const data = await request.formData();
|
||||
|
||||
const res = await fetch(`/api/article?id=eq.${data.get("id")}`, {
|
||||
const res = await fetch(`${API_BASE_PREFIX}/article?id=eq.${data.get("id")}`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { Actions, PageServerLoad } from "./$types";
|
||||
import { API_BASE_PREFIX } from "$lib/utils";
|
||||
|
||||
export const load: PageServerLoad = async ({ parent, params, cookies, fetch }) => {
|
||||
const articleData = await fetch(`/api/article?id=eq.${params.articleId}`, {
|
||||
const articleData = await fetch(`${API_BASE_PREFIX}/article?id=eq.${params.articleId}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -21,7 +22,7 @@ export const actions: Actions = {
|
||||
const data = await request.formData();
|
||||
const coverFile = data.get("cover-image") as File;
|
||||
|
||||
const uploadedImageData = await fetch(`/api/rpc/upload_file`, {
|
||||
const uploadedImageData = await fetch(`${API_BASE_PREFIX}/rpc/upload_file`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/octet-stream",
|
||||
@@ -40,7 +41,7 @@ export const actions: Actions = {
|
||||
return { success: false, message: uploadedImage.message };
|
||||
}
|
||||
|
||||
const res = await fetch(`/api/article?id=eq.${params.articleId}`, {
|
||||
const res = await fetch(`${API_BASE_PREFIX}/article?id=eq.${params.articleId}`, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -5,6 +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 } from "$lib/utils";
|
||||
|
||||
const { data, form } = $props<{ data: PageServerData; form: ActionData }>();
|
||||
</script>
|
||||
@@ -68,7 +69,10 @@
|
||||
</label>
|
||||
{#if data.article.cover_image}
|
||||
<Modal id="preview-cover-article-{data.article.id}" text="Preview">
|
||||
<img src={`/api/rpc/retrieve_file?id=${data.article.cover_image}`} alt="" />
|
||||
<img
|
||||
src={`${API_BASE_PREFIX}/rpc/retrieve_file?id=${data.article.cover_image}`}
|
||||
alt=""
|
||||
/>
|
||||
</Modal>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user