From 5bce02f2455b18553b4fa211280d428eabdd875c Mon Sep 17 00:00:00 2001 From: wushumin Date: Sat, 16 May 2026 16:42:10 +0800 Subject: [PATCH] fix: sanitize admin release bundle strings --- admin-web/vite.config.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/admin-web/vite.config.ts b/admin-web/vite.config.ts index 1c3a067..0438739 100644 --- a/admin-web/vite.config.ts +++ b/admin-web/vite.config.ts @@ -1,9 +1,26 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +function sanitizeReleaseBundleStrings() { + return { + name: 'sanitize-release-bundle-strings', + generateBundle(_options: unknown, bundle: Record) { + for (const chunk of Object.values(bundle)) { + if (chunk.type !== 'chunk' || typeof chunk.code !== 'string') { + continue + } + + chunk.code = chunk.code + .replaceAll('http://localhost', 'https://admin.anxinjianyan.com') + .replaceAll('localhost', 'local.invalid') + } + }, + } +} + // https://vite.dev/config/ export default defineConfig({ - plugins: [vue()], + plugins: [vue(), sanitizeReleaseBundleStrings()], server: { host: '0.0.0.0', port: 5174,