Fix Turbopack build: avoid cross-boundary import in EnvironmentContext
Some checks failed
Deploy to Server / deploy (push) Failing after 35s

Read sessionStorage directly instead of importing getCurrentEnvironment
from api.ts to avoid Turbopack module boundary resolution error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Peter Meier
2026-03-15 22:44:46 +01:00
parent a1e0287e6d
commit 6f2c4d8576

View File

@@ -1,7 +1,13 @@
"use client"; "use client";
import { createContext, useContext, useState, useEffect, type ReactNode } from "react"; import { createContext, useContext, useState, useEffect, type ReactNode } from "react";
import { getCurrentEnvironment, setCurrentEnvironment } from "@/lib/api"; import { setCurrentEnvironment } from "@/lib/api";
const ENVIRONMENT_STORAGE_KEY = "rustycms_admin_environment";
function readStoredEnvironment(): string | null {
if (typeof window === "undefined") return null;
return sessionStorage.getItem(ENVIRONMENT_STORAGE_KEY);
}
type EnvironmentContextType = { type EnvironmentContextType = {
environment: string | null; environment: string | null;
@@ -17,7 +23,7 @@ export function EnvironmentProvider({ children }: { children: ReactNode }) {
const [environment, setEnv] = useState<string | null>(null); const [environment, setEnv] = useState<string | null>(null);
useEffect(() => { useEffect(() => {
setEnv(getCurrentEnvironment()); setEnv(readStoredEnvironment());
}, []); }, []);
function setEnvironment(env: string) { function setEnvironment(env: string) {