Revamp navigation and styling; enhance API URL handling.
Replaced `Link` components with `NavLink` for active state support and added new sidebar navigation styling. Enhanced API URL handling to prevent mixed content when using HTTPS. Updated layout and CSS for better responsiveness and consistent design.
This commit is contained in:
@@ -1,4 +1,21 @@
|
||||
const API_URL = import.meta.env.VITE_API_URL || "http://localhost:8000/api/v1";
|
||||
function resolveApiUrl() {
|
||||
const raw = (import.meta.env.VITE_API_URL || "").trim();
|
||||
const fallback = "/api/v1";
|
||||
if (!raw) return fallback;
|
||||
|
||||
try {
|
||||
const parsed = new URL(raw, window.location.origin);
|
||||
if (window.location.protocol === "https:" && parsed.protocol === "http:") {
|
||||
// Avoid mixed-content when UI is served over HTTPS.
|
||||
parsed.protocol = "https:";
|
||||
}
|
||||
return parsed.toString().replace(/\/$/, "");
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
const API_URL = resolveApiUrl();
|
||||
|
||||
export async function apiFetch(path, options = {}, tokens, onUnauthorized) {
|
||||
const headers = {
|
||||
|
||||
Reference in New Issue
Block a user