Spaces:
Running
Running
Commit
ยท
121ec8d
1
Parent(s):
1c4b979
Debug: Enhanced HF Spaces environment detection
Browse files๐ Added comprehensive HF Spaces detection:
- Check window.huggingface.variables (original method)
- Check hostname for hf.space and huggingface.co domains
- Check for HF-specific meta tags
- Added detailed console logging for debugging
๐ฏ This should resolve the issue where auth modal
wasn't showing in HF Spaces environment
๐ Console logs will show exactly what's being detected
so we can identify why authentication wasn't triggered
frontend/src/context/AuthContext.tsx
CHANGED
|
@@ -149,13 +149,35 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|
| 149 |
dispatch({ type: "AUTH_SUCCESS", payload: normalizedResult });
|
| 150 |
} else {
|
| 151 |
// No OAuth redirect found, check if we need to show auth modal
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
if (isHFSpaces) {
|
| 154 |
// In HF Spaces, we require authentication - show the modal
|
|
|
|
| 155 |
dispatch({ type: "SET_LOADING", payload: false });
|
| 156 |
openModal("auth-login", "Sign in to AgentGraph");
|
| 157 |
} else {
|
| 158 |
// In local development, no auth required
|
|
|
|
| 159 |
dispatch({ type: "SET_LOADING", payload: false });
|
| 160 |
}
|
| 161 |
}
|
|
@@ -172,8 +194,12 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|
| 172 |
try {
|
| 173 |
dispatch({ type: "AUTH_START" });
|
| 174 |
|
| 175 |
-
// Check if we're in HF Spaces environment
|
| 176 |
-
const isHFSpaces =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
if (isHFSpaces) {
|
| 179 |
// Use HF OAuth
|
|
|
|
| 149 |
dispatch({ type: "AUTH_SUCCESS", payload: normalizedResult });
|
| 150 |
} else {
|
| 151 |
// No OAuth redirect found, check if we need to show auth modal
|
| 152 |
+
|
| 153 |
+
// Enhanced HF Spaces detection with debugging
|
| 154 |
+
const isHFSpaces =
|
| 155 |
+
// Method 1: Check for window.huggingface
|
| 156 |
+
(window.huggingface && window.huggingface.variables) ||
|
| 157 |
+
// Method 2: Check for HF-specific URL patterns
|
| 158 |
+
window.location.hostname.includes('hf.space') ||
|
| 159 |
+
window.location.hostname.includes('huggingface.co') ||
|
| 160 |
+
// Method 3: Check for HF-specific environment indicators
|
| 161 |
+
document.querySelector('meta[name="hf:space"]') !== null;
|
| 162 |
+
|
| 163 |
+
// Debug logging (remove in production)
|
| 164 |
+
console.log("๐ HF Spaces Environment Check:", {
|
| 165 |
+
hostname: window.location.hostname,
|
| 166 |
+
hasHuggingface: !!window.huggingface,
|
| 167 |
+
hasVariables: !!(window.huggingface && window.huggingface.variables),
|
| 168 |
+
hasHfMeta: !!document.querySelector('meta[name="hf:space"]'),
|
| 169 |
+
isHFSpaces,
|
| 170 |
+
href: window.location.href
|
| 171 |
+
});
|
| 172 |
+
|
| 173 |
if (isHFSpaces) {
|
| 174 |
// In HF Spaces, we require authentication - show the modal
|
| 175 |
+
console.log("๐ HF Spaces detected - showing auth modal");
|
| 176 |
dispatch({ type: "SET_LOADING", payload: false });
|
| 177 |
openModal("auth-login", "Sign in to AgentGraph");
|
| 178 |
} else {
|
| 179 |
// In local development, no auth required
|
| 180 |
+
console.log("๐ Local development detected - no auth required");
|
| 181 |
dispatch({ type: "SET_LOADING", payload: false });
|
| 182 |
}
|
| 183 |
}
|
|
|
|
| 194 |
try {
|
| 195 |
dispatch({ type: "AUTH_START" });
|
| 196 |
|
| 197 |
+
// Check if we're in HF Spaces environment
|
| 198 |
+
const isHFSpaces =
|
| 199 |
+
(window.huggingface && window.huggingface.variables) ||
|
| 200 |
+
window.location.hostname.includes('hf.space') ||
|
| 201 |
+
window.location.hostname.includes('huggingface.co') ||
|
| 202 |
+
document.querySelector('meta[name="hf:space"]') !== null;
|
| 203 |
|
| 204 |
if (isHFSpaces) {
|
| 205 |
// Use HF OAuth
|