Use environment variables for ports in web app

This commit is contained in:
thiloho
2024-08-10 22:20:57 +02:00
parent 0866e2631d
commit 162118bb56
23 changed files with 347 additions and 223 deletions

View File

@@ -6,7 +6,7 @@ export const load: PageServerLoad = async ({ fetch, cookies, url }) => {
const params = new URLSearchParams();
const baseFetchUrl = "http://localhost:3000/website";
const baseFetchUrl = `http://localhost:${process.env.ARCHTIKA_API_PORT}/website`;
if (searchQuery) {
params.append("title", `ilike.*${searchQuery}*`);
@@ -63,17 +63,20 @@ export const actions: Actions = {
createWebsite: async ({ request, fetch, cookies }) => {
const data = await request.formData();
const res = await fetch("http://localhost:3000/rpc/create_website", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
},
body: JSON.stringify({
content_type: data.get("content-type"),
title: data.get("title")
})
});
const res = await fetch(
`http://localhost:${process.env.ARCHTIKA_API_PORT}/rpc/create_website`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
},
body: JSON.stringify({
content_type: data.get("content-type"),
title: data.get("title")
})
}
);
if (!res.ok) {
const response = await res.json();
@@ -85,16 +88,19 @@ export const actions: Actions = {
updateWebsite: async ({ request, cookies, fetch }) => {
const data = await request.formData();
const res = await fetch(`http://localhost:3000/website?id=eq.${data.get("id")}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
},
body: JSON.stringify({
title: data.get("title")
})
});
const res = await fetch(
`http://localhost:${process.env.ARCHTIKA_API_PORT}/website?id=eq.${data.get("id")}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
},
body: JSON.stringify({
title: data.get("title")
})
}
);
if (!res.ok) {
const response = await res.json();
@@ -106,13 +112,16 @@ export const actions: Actions = {
deleteWebsite: async ({ request, cookies, fetch }) => {
const data = await request.formData();
const res = await fetch(`http://localhost:3000/website?id=eq.${data.get("id")}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
const res = await fetch(
`http://localhost:${process.env.ARCHTIKA_API_PORT}/website?id=eq.${data.get("id")}`,
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
}
}
});
);
if (!res.ok) {
const response = await res.json();