From 9ad5cc0639cd32012a5a67cbececaf9a90378a30 Mon Sep 17 00:00:00 2001 From: Heidi Date: Mon, 15 Jun 2026 09:09:54 +0100 Subject: [PATCH] ai generated solutions to our ai generated problems --- server.cjs | 1 + vite.config.js | 39 +-------------------------------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/server.cjs b/server.cjs index 96ebe8f..881b2d2 100644 --- a/server.cjs +++ b/server.cjs @@ -1883,6 +1883,7 @@ function htmlWithSeo(req, data) { const canonicalUrl = `${origin}${seo.path}` return data.toString('utf8') + .replace(/\s+integrity=(["'])sha(?:256|384|512)-[^"']+\1/g, '') .replaceAll('__PUBLIC_ORIGIN__', origin) .replaceAll('__SEO_TITLE__', escapeHtml(seo.title)) .replaceAll('__SEO_DESCRIPTION__', escapeHtml(seo.description)) diff --git a/vite.config.js b/vite.config.js index 04d6fd0..ca669a2 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,4 +1,3 @@ -import crypto from 'node:crypto' import path from 'node:path' import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' @@ -36,42 +35,6 @@ function obfuscate() { const MAX_TEAM_NAME_LENGTH = 80 -function sri() { - return { - name: 'sri', - apply: 'build', - enforce: 'post', - transformIndexHtml: { - order: 'post', - handler(html, ctx) { - const bundle = ctx?.bundle - if (!bundle) return html - - const hashFor = (fileName) => { - const asset = bundle[fileName] - if (!asset) return null - const source = asset.type === 'asset' ? asset.source : asset.code - const buf = Buffer.isBuffer(source) ? source : Buffer.from(source, 'utf8') - return `sha384-${crypto.createHash('sha384').update(buf).digest('base64')}` - } - - const tagPattern = /<(?:script|link)\b[^>]*\b(?:src|href)=["'](\/[^"']+)["'][^>]*>/g - return html.replace(tagPattern, (tag, url) => { - if (/\bintegrity=/.test(tag)) return tag - const fileName = url.replace(/^\//, '').split('?')[0].split('#')[0] - const integrity = hashFor(fileName) - if (!integrity) return tag - const closing = tag.endsWith('/>') ? ' />' : '>' - const body = tag.slice(0, -closing.length) - let out = `${body} integrity="${integrity}"` - if (!/\bcrossorigin\b/.test(tag)) out += ' crossorigin="anonymous"' - return `${out}${closing}` - }) - }, - }, - } -} - function isAllowedApiUrl(req) { const url = new URL(req.url, 'http://localhost') const params = url.searchParams @@ -207,7 +170,7 @@ export default defineConfig(({ mode }) => { return { root: path.resolve(__dirname, 'frontend'), publicDir: path.resolve(__dirname, 'frontend/public'), - plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss(), obfuscate(), sri()], + plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss(), obfuscate()], build: { outDir: path.resolve(__dirname, 'dist'), emptyOutDir: true,