mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-21 04:16:38 +00:00
major ui tweaks and refactoring
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user