enable dev|prod envs with simpler env vars system

This commit is contained in:
JCEEE
2026-08-06 18:09:47 +01:00
parent 2fc1668356
commit 4f384426d0
37 changed files with 447 additions and 256 deletions
+4 -6
View File
@@ -1,8 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { RequestEvent } from '@sveltejs/kit';
import { PROXY_URL } from '$lib/server/env';
const HONO_URL = PROXY_URL;
import { PROXY_URL } from '$app/env/public';
export function getSession(event: RequestEvent) {
return event.locals.session;
@@ -17,7 +15,7 @@ export function requireAuth(event: RequestEvent) {
}
export async function signup(email: string, password: string, famName: string, parentName?: string) {
const res = await fetch(`${HONO_URL}/api/admin/signup`, {
const res = await fetch(`${PROXY_URL}/api/admin/signup`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password, famName, parentName }),
@@ -29,7 +27,7 @@ export async function signup(email: string, password: string, famName: string, p
export async function login(email: string, password: string) {
console.log(email);
const res = await fetch(`${HONO_URL}/api/admin/login`, {
const res = await fetch(`${PROXY_URL}/api/admin/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
@@ -40,7 +38,7 @@ export async function login(email: string, password: string) {
}
export async function joinMember(inviteCode: string, name: string, deviceToken: string) {
const res = await fetch(`${HONO_URL}/api/members/join`, {
const res = await fetch(`${PROXY_URL}/api/members/join`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ inviteCode, name, deviceToken }),
+2 -4
View File
@@ -1,7 +1,5 @@
import { PROXY_URL } from '$lib/server/env';
import type { RequestEvent } from '@sveltejs/kit';
const HONO_URL = PROXY_URL;
import { PROXY_URL } from '$app/env/public';
function sessionHeaders(event: RequestEvent): Record<string, string> {
const s = event.locals.session;
@@ -19,7 +17,7 @@ async function request(
body?: unknown,
headers?: Record<string, string>
) {
const res = await fetch(`${HONO_URL}${path}`, {
const res = await fetch(`${PROXY_URL}${path}`, {
method,
headers: headers || { 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : undefined
+3 -1
View File
@@ -1,4 +1,6 @@
import { PB_ENDPOINT, PB_EMAIL, PB_PASSWORD } from './env';
import { PB_EMAIL, PB_PASSWORD } from '$app/env/private';
import { SERVER_IP } from '$app/env/public';
export const PB_ENDPOINT = import.meta.env.PROD ? '/pb' : `http://${SERVER_IP}:8090`;
let token: string | null = null;
let tokenExpiry = 0;