Fix: Authentification to use deployed URL rather than localhost
This commit is contained in:
parent
dd32378294
commit
54337509cf
1 changed files with 14 additions and 4 deletions
|
@ -1,10 +1,16 @@
|
|||
<script>
|
||||
import PocketBase from 'pocketbase';
|
||||
import Input from '$lib/components/base/Input.svelte';
|
||||
import { setContext } from 'svelte';
|
||||
import Button from '$lib/components/base/Button.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
const pb = new PocketBase('http://localhost:8090');
|
||||
let pb
|
||||
|
||||
let error = $state("")
|
||||
|
||||
onMount(() => {
|
||||
pb = new PocketBase(window.location.origin)
|
||||
})
|
||||
|
||||
async function login(form) {
|
||||
const formData = new FormData(form.target)
|
||||
|
@ -20,6 +26,7 @@
|
|||
console.log(pb.authStore.token);
|
||||
window.location.href = "/"
|
||||
} catch (err) {
|
||||
error = err.toString()
|
||||
console.log("Failed to log");
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +34,12 @@
|
|||
</script>
|
||||
|
||||
<div class="flex flex-col items-center mt-32 h-full p-8">
|
||||
<form class="flex flex-col gap-4 max-w-lg w-full" on:submit|preventDefault={(e) => login(e)}>
|
||||
<form class="flex flex-col gap-4 max-w-lg w-full" onsubmit={(e) => {e.preventDefault(); login(e)}}>
|
||||
<Input name="email" placeholder="email" type="email" />
|
||||
<Input name="password" placeholder="password" type="password" />
|
||||
{#if error != ""}
|
||||
<span class="bg-red-200 text-sm rounded-md p-2">{error}</span>
|
||||
{/if}
|
||||
<Button>Connexion</Button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue