Fix Turbopack build: avoid cross-boundary import in EnvironmentContext
Some checks failed
Deploy to Server / deploy (push) Failing after 35s
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:
@@ -1,7 +1,13 @@
|
||||
"use client";
|
||||
|
||||
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 = {
|
||||
environment: string | null;
|
||||
@@ -17,7 +23,7 @@ export function EnvironmentProvider({ children }: { children: ReactNode }) {
|
||||
const [environment, setEnv] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setEnv(getCurrentEnvironment());
|
||||
setEnv(readStoredEnvironment());
|
||||
}, []);
|
||||
|
||||
function setEnvironment(env: string) {
|
||||
|
||||
Reference in New Issue
Block a user