Skip to content

Commit 933613c

Browse files
feat : [reverse-proxy] - Handle 202 (Cuttently Building)
1 parent d78addd commit 933613c

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Building...</title>
7+
<style>
8+
:root {
9+
--primary-600: #2563EB;
10+
--primary-500: #3B82F6;
11+
--primary-800: #1D4ED8;
12+
--primary-300: #93C5FD;
13+
--primary-900: #1E40AF;
14+
--gray-900: #111827;
15+
--gray-500: #6B7280;
16+
--gray-400: #9CA3AF;
17+
--white: #fff;
18+
}
19+
html, body {
20+
height: 100%;
21+
margin: 0;
22+
padding: 0;
23+
}
24+
body {
25+
background-color: var(--white);
26+
color: var(--gray-900);
27+
width: 100vw;
28+
height: 100vh;
29+
min-height: 100vh;
30+
font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
31+
}
32+
.center-section {
33+
display: flex;
34+
align-items: center;
35+
justify-content: center;
36+
width: 100vw;
37+
height: 100vh;
38+
background-color: var(--white);
39+
}
40+
.container {
41+
max-width: 1280px;
42+
margin: 0 auto;
43+
}
44+
.text-center {
45+
text-align: center;
46+
max-width: 1024px;
47+
margin: 0 auto;
48+
}
49+
.building-icon {
50+
font-size: 4rem;
51+
color: var(--primary-600);
52+
margin-bottom: 1rem;
53+
}
54+
.building-title {
55+
margin-bottom: 1rem;
56+
font-size: 2rem;
57+
letter-spacing: -0.02em;
58+
font-weight: 700;
59+
color: var(--gray-900);
60+
}
61+
@media (min-width: 768px) {
62+
.building-title {
63+
font-size: 2.5rem;
64+
}
65+
}
66+
.building-message {
67+
margin-bottom: 1rem;
68+
font-size: 1.125rem;
69+
font-weight: 300;
70+
color: var(--gray-500);
71+
max-width: 600px;
72+
margin-left: auto;
73+
margin-right: auto;
74+
}
75+
/* Dark mode support */
76+
@media (prefers-color-scheme: dark) {
77+
body, .center-section {
78+
background-color: var(--gray-900);
79+
color: var(--white);
80+
}
81+
.building-icon {
82+
color: var(--primary-500);
83+
}
84+
.building-title {
85+
color: var(--white);
86+
}
87+
.building-message {
88+
color: var(--gray-400);
89+
}
90+
}
91+
</style>
92+
</head>
93+
<body>
94+
<section class="center-section">
95+
<div class="container">
96+
<div class="text-center">
97+
<div class="building-icon">🚧</div>
98+
<p class="building-title">Currently building. Please wait...</p>
99+
<p class="building-message">
100+
Your site is being prepared. This may take a few moments.
101+
</p>
102+
</div>
103+
</div>
104+
</section>
105+
</body>
106+
</html>

src/reverse-proxy/src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,27 @@ const resolveTarget = async (hostname: string): Promise<string> => {
108108

109109

110110

111+
const checkStorageExists = async (target: string): Promise<boolean> => {
112+
try {
113+
const res = await fetch(`${target}/index.html`, { method: 'HEAD' });
114+
return res.ok;
115+
} catch (err) {
116+
return false;
117+
}
118+
};
119+
120+
121+
111122
// Middleware to handle proxying
112123
app.use(asyncHandler(async (req: Request, res: Response) => {
113124
const target = await resolveTarget(req.hostname);
114125
req.target = target;
115126

127+
const exists = await checkStorageExists(target);
128+
if (!exists) {
129+
return res.status(200).sendFile(path.join(__dirname, 'errors', '202.html'));
130+
}
131+
116132
proxy.web(req, res, { target, changeOrigin: true }, (err) => {
117133
if (err) {
118134
console.error('Proxy error:', err);

0 commit comments

Comments
 (0)