Skip to content

Commit 27681cf

Browse files
fix: resolve deployment login loading hang & fix typescript compilation errors
1 parent 97a101a commit 27681cf

3 files changed

Lines changed: 54 additions & 26 deletions

File tree

src/app/analysis/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ function AnalysisHUDPageContent() {
14751475
{gradeDetail && gradeDetail.step_grades && gradeDetail.step_grades[selectedQuestionIndex]
14761476
? gradeDetail.step_grades[selectedQuestionIndex].justification
14771477
: activeStudent.answers && activeStudent.answers[activeQuestion.id]
1478-
? `OzymorLab analysis has graded this submission. Overall grade assignment: ${activeStudent.grade || "Verified"}.`
1478+
? `OzymorLab analysis has graded this submission. Overall grade assignment: ${activeStudent.score || "Verified"}.`
14791479
: "No answer provided for this question, so no step traces or analysis can be generated."}
14801480
</p>
14811481
</div>

src/app/context/AuthContext.tsx

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,62 @@ import { supabase } from "../../lib/supabaseClient";
66
const API_BASE = process.env.NEXT_PUBLIC_API_URL || "https://edeziav2.onrender.com/api/v1";
77

88
const safeFetch = async (url: string, options: RequestInit = {}): Promise<Response> => {
9-
if (url.includes(",")) {
10-
const parts = url.split(",");
11-
const firstBase = parts[0];
12-
const rest = parts.slice(1).join(",");
13-
14-
// Resolve path from secondary base dynamically
9+
const controller = new AbortController();
10+
const id = setTimeout(() => controller.abort(), 6000); // 6 seconds timeout
11+
12+
const fetchOptions = {
13+
...options,
14+
signal: controller.signal
15+
};
16+
17+
try {
18+
if (url.includes(",")) {
19+
const parts = url.split(",");
20+
const firstBase = parts[0];
21+
const rest = parts.slice(1).join(",");
22+
23+
// Resolve path from secondary base dynamically
1524
const secondBase = "https://edeziav2.onrender.com/api/v1";
16-
let path = "";
17-
if (rest.startsWith(secondBase)) {
18-
path = rest.substring(secondBase.length);
19-
} else {
20-
const idx = rest.indexOf("/api/v1");
21-
if (idx !== -1) {
22-
path = rest.substring(idx + "/api/v1".length);
25+
let path = "";
26+
if (rest.startsWith(secondBase)) {
27+
path = rest.substring(secondBase.length);
28+
} else {
29+
const idx = rest.indexOf("/api/v1");
30+
if (idx !== -1) {
31+
path = rest.substring(idx + "/api/v1".length);
32+
}
33+
}
34+
35+
const url1 = `${firstBase}${path}`;
36+
const url2 = rest;
37+
38+
try {
39+
const res = await fetch(url1, fetchOptions);
40+
clearTimeout(id);
41+
return res;
42+
} catch (err) {
43+
console.warn(`Local API offline at ${url1}, falling back to remote production at ${url2}`, err);
44+
45+
// Reset timeout for fallback fetch
46+
const fallbackController = new AbortController();
47+
const fallbackId = setTimeout(() => fallbackController.abort(), 6000);
48+
try {
49+
const res = await fetch(url2, { ...options, signal: fallbackController.signal });
50+
clearTimeout(fallbackId);
51+
return res;
52+
} catch (fallbackErr) {
53+
clearTimeout(fallbackId);
54+
throw fallbackErr;
55+
}
2356
}
2457
}
25-
26-
const url1 = `${firstBase}${path}`;
27-
const url2 = rest;
28-
29-
try {
30-
return await fetch(url1, options);
31-
} catch (err) {
32-
console.warn(`Local API offline at ${url1}, falling back to remote production at ${url2}`, err);
33-
return await fetch(url2, options);
34-
}
58+
const res = await fetch(url, fetchOptions);
59+
clearTimeout(id);
60+
return res;
61+
} catch (error) {
62+
clearTimeout(id);
63+
throw error;
3564
}
36-
return fetch(url, options);
3765
};
3866

3967
interface User {

src/app/landing/LandingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ export default function LandingPage() {
400400
</p>
401401
</div>
402402

403-
<div className="lp-hero__ui" style={{ marginScale: 1, width: "100%", maxWidth: "1000px", margin: "0 auto" }}>
403+
<div className="lp-hero__ui" style={{ width: "100%", maxWidth: "1000px", margin: "0 auto" }}>
404404
<div className="lp-hero-ui">
405405
<div className="lp-hero-ui__sidebar">
406406
<div className="lp-hero-ui__sidebar-logo"><LogoIcon /></div>

0 commit comments

Comments
 (0)