@kmugalkhod/lightcode 0.13.0 → 0.13.1
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/cli.js +1 -1
- package/package.json +1 -1
- package/server.js +5 -1
package/cli.js
CHANGED
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -515,6 +515,9 @@ function loadWebAuthStateFromEnvironment(env = Bun.env) {
|
|
|
515
515
|
function isPublicWebPath(pathname) {
|
|
516
516
|
return pathname === "/healthz" || pathname === "/app" || pathname === "/app/" || pathname.startsWith("/app/");
|
|
517
517
|
}
|
|
518
|
+
function isPublicWebAppPath(pathname) {
|
|
519
|
+
return pathname === "/app" || pathname === "/app/" || pathname.startsWith("/app/");
|
|
520
|
+
}
|
|
518
521
|
function looksLikeBrowserRequest(request) {
|
|
519
522
|
const headers = request.headers;
|
|
520
523
|
if (headers.get("x-lightcode-client")?.toLowerCase() === "web") {
|
|
@@ -577,8 +580,9 @@ function createWebSecurityMiddleware(options = {}) {
|
|
|
577
580
|
return jsonSecurityError(c, 403, "web_origin_forbidden", "The browser origin is not allowed.");
|
|
578
581
|
}
|
|
579
582
|
const fetchSite = request.headers.get("sec-fetch-site");
|
|
583
|
+
const isBootstrapDocumentNavigation = isPublicWebAppPath(pathname) && (request.method === "GET" || request.method === "HEAD") && request.headers.get("sec-fetch-mode") === "navigate" && request.headers.get("sec-fetch-dest") === "document";
|
|
580
584
|
const allowedFetchSites = publicPath ? new Set(["same-origin", "none"]) : new Set(["same-origin"]);
|
|
581
|
-
if (browserRequest && fetchSite !== null && !allowedFetchSites.has(fetchSite)) {
|
|
585
|
+
if (browserRequest && fetchSite !== null && !allowedFetchSites.has(fetchSite) && !(fetchSite === "cross-site" && isBootstrapDocumentNavigation)) {
|
|
582
586
|
return jsonSecurityError(c, 403, "web_fetch_forbidden", "Cross-site browser requests are not allowed.");
|
|
583
587
|
}
|
|
584
588
|
if (!publicPath && browserRequest) {
|