From c374020f15160587c36b400d551c285f6f095988 Mon Sep 17 00:00:00 2001 From: Sahil Malhotra Date: Mon, 15 Dec 2025 11:14:21 -0500 Subject: [PATCH 1/4] impliment middleware to prevent xss attacks --- frontend/vite-xss-middleware.ts | 41 +++++++++++++++++++++++++++++++++ frontend/vite.config.ts | 5 ++-- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 frontend/vite-xss-middleware.ts diff --git a/frontend/vite-xss-middleware.ts b/frontend/vite-xss-middleware.ts new file mode 100644 index 0000000..a20238d --- /dev/null +++ b/frontend/vite-xss-middleware.ts @@ -0,0 +1,41 @@ +// vite-xss-fix.ts +import { Plugin } from 'vite'; + +export function viteXssMiddleware(): Plugin { + const middleware = (req: any, res: any, next: any) => { + const originalEnd = res.end; + const chunks: any[] = []; + + res.end = function(chunk?: any) { + if (chunk) chunks.push(Buffer.from(chunk)); + + const body = Buffer.concat(chunks).toString(); + + // If Vite's error message is reflecting user input, replace it + if (body.includes('did you mean to visit') && body.includes(' Date: Mon, 15 Dec 2025 11:19:13 -0500 Subject: [PATCH 2/4] run lint --- frontend/vite-xss-middleware.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/vite-xss-middleware.ts b/frontend/vite-xss-middleware.ts index a20238d..215c5e6 100644 --- a/frontend/vite-xss-middleware.ts +++ b/frontend/vite-xss-middleware.ts @@ -6,15 +6,14 @@ export function viteXssMiddleware(): Plugin { const originalEnd = res.end; const chunks: any[] = []; - res.end = function(chunk?: any) { + res.end = function (chunk?: any) { if (chunk) chunks.push(Buffer.from(chunk)); - + const body = Buffer.concat(chunks).toString(); - + // If Vite's error message is reflecting user input, replace it if (body.includes('did you mean to visit') && body.includes(' Date: Mon, 15 Dec 2025 11:20:29 -0500 Subject: [PATCH 3/4] update index to not include intermediary title --- frontend/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/index.html b/frontend/index.html index 1154229..6285209 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - Rems Intermediary UI + Pharmacy Information Management System
From 286a704bd1c381d526fd4353ab186117ebe7b830 Mon Sep 17 00:00:00 2001 From: Sahil Malhotra Date: Mon, 15 Dec 2025 11:21:12 -0500 Subject: [PATCH 4/4] update title to be PIMS short hand --- frontend/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/index.html b/frontend/index.html index 6285209..d238940 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - Pharmacy Information Management System + PIMS Pharmacy