Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import urls from '$lib/config';
import { config } from '$lib/config';
import type { Secret } from '$lib/secret';

async function getAuth() {
return fetch(urls.backendAuthUrl, {
return fetch(config.backendAuthUrl, {
method: 'GET',
mode: 'cors',
cache: 'no-cache',
Expand All @@ -14,7 +14,7 @@ async function getAuth() {
}

async function deleteAuth() {
return fetch(urls.backendAuthUrl, {
return fetch(config.backendAuthUrl, {
method: 'DELETE',
mode: 'cors',
cache: 'no-cache',
Expand All @@ -26,7 +26,7 @@ async function deleteAuth() {
}

async function getSecrets() {
return fetch(urls.backendSecretsUrl, {
return fetch(config.backendSecretsUrl, {
method: 'GET',
mode: 'cors',
cache: 'no-cache',
Expand All @@ -38,7 +38,7 @@ async function getSecrets() {
}

async function postSecret(secret: Secret) {
return fetch(urls.backendSecretsUrl, {
return fetch(config.backendSecretsUrl, {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
Expand Down
27 changes: 14 additions & 13 deletions frontend/src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const localhost = 'http://localhost:4000';
const ip = 'http://192.168.178.52:8080';
const deployed = 'https://kayvault.torfstack.com';
export interface AppConfig {
backendSecretsUrl: string;
backendAuthUrl: string;
backendAuthStartUrl: string;
}

export let config: AppConfig;

const secretPath = '/api/secrets';
const authPath = '/api/auth';

const backendUrl = deployed;
const backendSecretsUrl = backendUrl + secretPath;
const backendAuthUrl = backendUrl + authPath;
const backendAuthStartUrl = backendUrl + authPath + '/start';

export default {
backendSecretsUrl,
backendAuthUrl,
backendAuthStartUrl
};
export async function loadConfig(): Promise<void> {
config = {
backendSecretsUrl: secretPath,
backendAuthUrl: authPath,
backendAuthStartUrl: authPath + '/start',
};
}
2 changes: 0 additions & 2 deletions frontend/src/routes/+layout.js

This file was deleted.

9 changes: 9 additions & 0 deletions frontend/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { loadConfig } from '$lib/config';

export const ssr = false;
export const prerender = true;

export async function load() {
await loadConfig();
return {};
}
4 changes: 2 additions & 2 deletions frontend/src/routes/login.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import cfg from "$lib/config";
import {config} from "$lib/config";
import {Button, Checkbox, Img, Input, Label} from "flowbite-svelte";
import {EnvelopeSolid} from "flowbite-svelte-icons";
import KayHeader from "../components/KayHeader.svelte";
Expand All @@ -8,7 +8,7 @@
let password = $state("");

function signInWithProvider() {
window.open(cfg.backendAuthStartUrl, "_self");
window.open(config.backendAuthStartUrl, "_self");
}
</script>

Expand Down