major ui tweaks and refactoring

This commit is contained in:
Milo Schwartz
2025-01-04 20:22:01 -05:00
parent 51bf5c1408
commit 64158a823b
91 changed files with 1791 additions and 1246 deletions

View File

@@ -1,8 +1,11 @@
import { cookies } from "next/headers";
import { pullEnv } from "../pullEnv";
export async function authCookieHeader() {
const env = pullEnv();
const allCookies = await cookies();
const cookieName = process.env.SESSION_COOKIE_NAME!;
const cookieName = env.server.sessionCookieName;
const sessionId = allCookies.get(cookieName)?.value ?? null;
return {
headers: {

View File

@@ -1,9 +1,9 @@
import { env } from "@app/lib/types/env";
import { Env } from "@app/lib/types/env";
import axios, { AxiosInstance } from "axios";
let apiInstance: AxiosInstance | null = null;
export function createApiClient({ env }: { env: env }): AxiosInstance {
export function createApiClient({ env }: { env: Env }): AxiosInstance {
if (apiInstance) {
return apiInstance;
}
@@ -16,9 +16,9 @@ export function createApiClient({ env }: { env: env }): AxiosInstance {
let baseURL;
const suffix = "api/v1";
if (window.location.port === env.NEXT_PORT) {
if (window.location.port === env.server.nextPort) {
// this means the user is addressing the server directly
baseURL = `${window.location.protocol}//${window.location.hostname}:${env.SERVER_EXTERNAL_PORT}/${suffix}`;
baseURL = `${window.location.protocol}//${window.location.hostname}:${env.server.externalPort}/${suffix}`;
axios.defaults.withCredentials = true;
} else {
// user is accessing through a proxy