don't use CDN's for most things. Get rid of JsDelivr.net from CSP as well.

This commit is contained in:
KingKDot
2026-04-18 21:16:29 -05:00
parent 1ee4ae96d5
commit 4cc1f47822
43 changed files with 1339 additions and 423 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ export const CORS_HEADERS = {
};
export const SECURITY_HEADERS = {
"Content-Security-Policy": "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://unpkg.com; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://fonts.googleapis.com; img-src 'self' data: blob: https://cdn.jsdelivr.net https://a.tile.openstreetmap.org https://b.tile.openstreetmap.org https://c.tile.openstreetmap.org https://tile.openstreetmap.org https://a.basemaps.cartocdn.com https://b.basemaps.cartocdn.com https://c.basemaps.cartocdn.com https://d.basemaps.cartocdn.com; font-src 'self' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://fonts.gstatic.com; connect-src 'self' wss: ws: https://cdn.jsdelivr.net; object-src blob:",
"Content-Security-Policy": "default-src 'self'; script-src 'self'; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https://a.basemaps.cartocdn.com https://b.basemaps.cartocdn.com https://c.basemaps.cartocdn.com https://d.basemaps.cartocdn.com; font-src 'self'; connect-src 'self' wss: ws:; object-src blob:",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"X-XSS-Protection": "1; mode=block",
@@ -74,7 +74,9 @@ export async function handleAssetsRoutes(
return new Response("Not found", { status: 404 });
}
if (!(req.method === "GET" && url.pathname.startsWith("/assets/"))) {
const isAssets = req.method === "GET" && url.pathname.startsWith("/assets/");
const isVendor = req.method === "GET" && url.pathname.startsWith("/vendor/");
if (!isAssets && !isVendor) {
return null;
}
@@ -89,8 +91,10 @@ export async function handleAssetsRoutes(
return new Response("Not found", { status: 404 });
}
const assetsRoot = path.join(deps.PUBLIC_ROOT, "assets");
const relativePath = decodedPath.replace(/^\/assets\//, "");
const subdir = isVendor ? "vendor" : "assets";
const prefix = isVendor ? /^\/vendor\// : /^\/assets\//;
const assetsRoot = path.join(deps.PUBLIC_ROOT, subdir);
const relativePath = decodedPath.replace(prefix, "");
const resolvedPath = path.resolve(assetsRoot, relativePath);
const rootWithSep = assetsRoot.endsWith(path.sep) ? assetsRoot : `${assetsRoot}${path.sep}`;
@@ -770,19 +770,11 @@ export async function handlePluginRoutes(
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>${pluginId} - Overlord Plugin</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="/vendor/inter/400.css" />
<link rel="stylesheet" href="/vendor/inter/600.css" />
<link rel="stylesheet" href="/vendor/inter/700.css" />
<link rel="stylesheet" href="/assets/tailwind.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="/vendor/fontawesome/css/all.min.css" />
<link rel="stylesheet" href="/assets/main.css" />
<link rel="stylesheet" href="/assets/custom.css" />
${pluginHeadExtras}