Spaces:
Running
Running
Merge pull request #117 from anurag008w/codex/fix-bugs-in-start.sh,-health-server.js,-env-builder.js,-env-5ae6s5
Browse files- health-server.js +3 -7
health-server.js
CHANGED
|
@@ -674,7 +674,7 @@ const server = http.createServer(async (req, res) => {
|
|
| 674 |
const body = await readBody(req);
|
| 675 |
const token = decodeURIComponent((body.match(/(?:^|&)token=([^&]*)/) || [])[1] || "").replace(/\+/g, " ");
|
| 676 |
if (safeEqual(token, GATEWAY_TOKEN)) {
|
| 677 |
-
const cookie = `hc_env_auth=${encodeURIComponent(GATEWAY_TOKEN)}; Path=/; HttpOnly; SameSite=None; Secure; Max-Age=86400`;
|
| 678 |
res.writeHead(302, { Location: "/env-builder", "Set-Cookie": cookie, "Cache-Control": "no-store" });
|
| 679 |
return res.end();
|
| 680 |
}
|
|
@@ -686,7 +686,7 @@ const server = http.createServer(async (req, res) => {
|
|
| 686 |
}
|
| 687 |
|
| 688 |
if (pathname === "/env-builder/logout") {
|
| 689 |
-
res.writeHead(302, { Location: "/env-builder", "Set-Cookie": "hc_env_auth=; Path=/; HttpOnly; SameSite=None; Secure; Max-Age=0", "Cache-Control": "no-store" });
|
| 690 |
return res.end();
|
| 691 |
}
|
| 692 |
|
|
@@ -704,13 +704,9 @@ const server = http.createServer(async (req, res) => {
|
|
| 704 |
}
|
| 705 |
|
| 706 |
if (pathname === "/env-builder.js") {
|
| 707 |
-
if (!isEnvBuilderAuthed(req)) {
|
| 708 |
-
res.writeHead(401, { "Content-Type": "text/plain", "Cache-Control": "no-store", "Vary": "Cookie" });
|
| 709 |
-
return res.end("Unauthorized");
|
| 710 |
-
}
|
| 711 |
try {
|
| 712 |
const js = fs.readFileSync(require("path").join(__dirname, "env-builder.js"), "utf8");
|
| 713 |
-
res.writeHead(200, { "Content-Type": "application/javascript", "Cache-Control": "no-store"
|
| 714 |
return res.end(js);
|
| 715 |
} catch (exc) {
|
| 716 |
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
|
|
| 674 |
const body = await readBody(req);
|
| 675 |
const token = decodeURIComponent((body.match(/(?:^|&)token=([^&]*)/) || [])[1] || "").replace(/\+/g, " ");
|
| 676 |
if (safeEqual(token, GATEWAY_TOKEN)) {
|
| 677 |
+
const cookie = `hc_env_auth=${encodeURIComponent(GATEWAY_TOKEN)}; Path=/; HttpOnly; SameSite=None; Secure; Partitioned; Max-Age=86400`;
|
| 678 |
res.writeHead(302, { Location: "/env-builder", "Set-Cookie": cookie, "Cache-Control": "no-store" });
|
| 679 |
return res.end();
|
| 680 |
}
|
|
|
|
| 686 |
}
|
| 687 |
|
| 688 |
if (pathname === "/env-builder/logout") {
|
| 689 |
+
res.writeHead(302, { Location: "/env-builder", "Set-Cookie": "hc_env_auth=; Path=/; HttpOnly; SameSite=None; Secure; Partitioned; Max-Age=0", "Cache-Control": "no-store" });
|
| 690 |
return res.end();
|
| 691 |
}
|
| 692 |
|
|
|
|
| 704 |
}
|
| 705 |
|
| 706 |
if (pathname === "/env-builder.js") {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
try {
|
| 708 |
const js = fs.readFileSync(require("path").join(__dirname, "env-builder.js"), "utf8");
|
| 709 |
+
res.writeHead(200, { "Content-Type": "application/javascript", "Cache-Control": "no-store" });
|
| 710 |
return res.end(js);
|
| 711 |
} catch (exc) {
|
| 712 |
res.writeHead(404, { "Content-Type": "text/plain" });
|