@tomorrowos/sdk 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-cms",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "CMS server on @tomorrowos/sdk. Add your UI (React, static files, etc.) alongside this server.",
5
5
  "private": true,
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "start": "tsx server.ts"
13
13
  },
14
14
  "dependencies": {
15
- "@tomorrowos/sdk": "^1.1.0",
15
+ "@tomorrowos/sdk": "^1.1.2",
16
16
  "dotenv": "^17.2.3",
17
17
  "tsx": "^4.19.0"
18
18
  },
@@ -9,5 +9,5 @@
9
9
  "noEmit": true,
10
10
  "types": ["node"]
11
11
  },
12
- "include": ["server.ts"]
12
+ "include": ["server.ts", "cms-auth.ts"]
13
13
  }
@@ -200,12 +200,16 @@ export async function handleCmsAuth(
200
200
 
201
201
  if (isDevicePublicPath(method, pathname)) return false;
202
202
 
203
- if (method === "GET" && pathname === "/login") {
203
+ if ((method === "GET" || method === "HEAD") && pathname === "/login") {
204
204
  res.writeHead(200, {
205
205
  "Content-Type": "text/html; charset=utf-8",
206
206
  "Cache-Control": "no-store"
207
207
  });
208
- res.end(loginPageHtml());
208
+ if (method === "HEAD") {
209
+ res.end();
210
+ } else {
211
+ res.end(loginPageHtml());
212
+ }
209
213
  return true;
210
214
  }
211
215
 
@@ -244,16 +248,25 @@ export async function handleCmsAuth(
244
248
  const cookies = parseCookies(req);
245
249
  if (verifySession(password, cookies[COOKIE_NAME])) return false;
246
250
 
247
- if (wantsHtml(req) && method === "GET") {
248
- res.writeHead(303, { Location: "/login" });
249
- res.end();
251
+ // Serve login with HTTP 200 (no 303). Replit Publish readiness probes `/` and
252
+ // fails if it follows a redirect chain to /login.
253
+ if (wantsHtml(req) && (method === "GET" || method === "HEAD")) {
254
+ res.writeHead(200, {
255
+ "Content-Type": "text/html; charset=utf-8",
256
+ "Cache-Control": "no-store"
257
+ });
258
+ if (method === "HEAD") {
259
+ res.end();
260
+ } else {
261
+ res.end(loginPageHtml());
262
+ }
250
263
  return true;
251
264
  }
252
265
 
253
266
  sendJson(res, 401, {
254
267
  status: "failed",
255
268
  error:
256
- "Control Panel authentication required. Sign in at /login or set cookie after POST /login."
269
+ "CMS authentication required. Sign in at /login or set cookie after POST /login."
257
270
  });
258
271
  return true;
259
272
  }