moved accounts backend to session lib

This commit is contained in:
Jonas_Jones 2025-03-07 20:27:56 +01:00
parent 10cc36000c
commit e5c9c351e7
3 changed files with 7 additions and 4 deletions

View file

@ -1,3 +1,5 @@
export const ACCOUNTS_WORKER_URL = 'https://accounts.jonasjones.dev';
export function getSessionKey() {
const match = document.cookie.match(/(^| )sessionKey=([^;]+)/);
return match ? match[2] : null;

View file

@ -1,6 +1,7 @@
<script>
import { navigate } from 'svelte-routing';
import { setSessionKey } from '$lib/session.js';
import { onMount } from 'svelte';
import { setSessionKey, ACCOUNTS_WORKER_URL } from '$lib/session.js';
import { page } from '$app/state';
let email = '';
let password = '';
@ -9,7 +10,7 @@
const handleLogin = async () => {
try {
const response = await fetch('https://accounts.jonasjones.dev/login', {
const response = await fetch(ACCOUNTS_WORKER_URL + '/login', {
method: 'POST',
body: JSON.stringify({ email, password }),
headers: {

View file

@ -1,6 +1,6 @@
<script>
import { navigate } from 'svelte-routing';
import { setSessionKey } from '$lib/session.js';
import { setSessionKey, ACCOUNTS_WORKER_URL } from '$lib/session.js';
import { page } from '$app/state';
let username = '';
let firstname = '';
@ -12,7 +12,7 @@
const handleLogin = async () => {
try {
const response = await fetch('https://accounts.jonasjones.dev/register', {
const response = await fetch(ACCOUNTS_WORKER_URL + '/register', {
method: 'POST',
body: JSON.stringify({ email, password, username, firstname, lastname }),
headers: {