@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.
- package/REPLIT_SETUP.md +50 -17
- package/VERCEL_QUESTIONS.md +4 -3
- package/VERCEL_SETUP.md +106 -19
- package/package.json +1 -1
- package/templates/cms-starter/.replit +3 -0
- package/templates/cms-starter/cms-auth.ts +19 -6
- package/templates/cms-starter/package-lock.json +2462 -605
- package/templates/cms-starter/package.json +2 -2
- package/templates/cms-starter/tsconfig.json +1 -1
- package/templates/cms-starter-v0/cms-auth.ts +19 -6
- package/templates/cms-starter-v0/package-lock.json +3772 -0
- package/templates/cms-starter-v0/package.json +2 -2
- package/templates/cms-starter-v0/tsconfig.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-cms",
|
|
3
|
-
"version": "1.1.
|
|
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.
|
|
15
|
+
"@tomorrowos/sdk": "^1.1.2",
|
|
16
16
|
"dotenv": "^17.2.3",
|
|
17
17
|
"tsx": "^4.19.0"
|
|
18
18
|
},
|
|
@@ -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
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
"
|
|
269
|
+
"CMS authentication required. Sign in at /login or set cookie after POST /login."
|
|
257
270
|
});
|
|
258
271
|
return true;
|
|
259
272
|
}
|