From 85fed61b106ec31c938518c84d1652b8a76384e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Mon, 13 Feb 2023 11:43:24 +0100 Subject: [PATCH] Fix Mixed Content error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rūdolfs Ošiņš --- src/lib/session.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib/session.ts b/src/lib/session.ts index c24702a5e..6e386cfd8 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -7,6 +7,8 @@ interface Session { const store = writable(undefined); export const sessionStore = derived(store, s => s); +const endpoint = "http://localhost:8080/api/v1/sessions"; + export async function authenticate(params: { id: string; signature: string; @@ -14,14 +16,11 @@ export async function authenticate(params: { }): Promise<"success" | "failure"> { disconnect(); - const request = await fetch( - `http://0.0.0.0:8080/api/v1/sessions/${params.id}`, - { - method: "PUT", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ sig: params.signature, pk: params.publicKey }), - }, - ); + const request = await fetch(`${endpoint}/${params.id}`, { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ sig: params.signature, pk: params.publicKey }), + }); if (request.ok) { save(params.id, params.publicKey); return "success"; @@ -36,7 +35,7 @@ export async function disconnect() { return "success"; } - await fetch(`http://0.0.0.0:8080/api/v1/sessions/${session.id}`, { + await fetch(`${endpoint}/${session.id}`, { method: "DELETE", headers: { "Content-Type": "application/json",