mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-20 01:50:58 +00:00
fix(frontend): real dark mode + silence dev proxy ECONNREFUSED noise
Two issues from running login.html against no Go backend:
1. Dark mode toggled the body class but didn't actually re-theme any
AD-Vue components. The legacy panel relied on custom.min.css which
we haven't ported. AD-Vue 4 ships its own dark algorithm — wrap
LoginPage in <a-config-provider :theme="{ algorithm }"> driven by
our useTheme state, and AD-Vue restyles every component for free.
Page chrome (background, card, title) gets explicit .is-dark CSS
since the algorithm only covers AD-Vue components.
2. Vite logged every failed proxy attempt loudly. When the Go panel
isn't running locally that's pure noise. Added a configure()
callback that swallows ECONNREFUSED specifically; real errors
(timeouts, 5xx, anything else) still surface.
Both fixes are dev-experience only — production build is unchanged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+25
-5
@@ -6,6 +6,27 @@ import path from 'node:path';
|
||||
// via embed.FS without reaching outside the web/ tree.
|
||||
const outDir = path.resolve(__dirname, '../web/dist');
|
||||
|
||||
// Build a proxy config that suppresses ECONNREFUSED noise when the Go
|
||||
// backend isn't running locally. Real errors (timeouts, 5xx, etc.) still
|
||||
// surface in the Vite log.
|
||||
function makeBackendProxy(target, patterns) {
|
||||
const config = {};
|
||||
for (const pattern of patterns) {
|
||||
config[pattern] = {
|
||||
target,
|
||||
changeOrigin: true,
|
||||
configure(proxy) {
|
||||
proxy.on('error', (err) => {
|
||||
if (err.code === 'ECONNREFUSED') return;
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('[proxy]', err);
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
@@ -30,13 +51,12 @@ export default defineConfig({
|
||||
server: {
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
proxy: {
|
||||
// Proxy API calls during `npm run dev` to the local Go panel.
|
||||
proxy: makeBackendProxy('http://localhost:2053', [
|
||||
// Patterns are anchored regex so /login.html and /index.html
|
||||
// (which Vite serves itself) are NOT forwarded — only the bare
|
||||
// backend paths and their sub-routes.
|
||||
'^/(login|logout|getTwoFactorEnable)$': 'http://localhost:2053',
|
||||
'^/(panel|server)(/|$)': 'http://localhost:2053',
|
||||
},
|
||||
'^/(login|logout|getTwoFactorEnable)$',
|
||||
'^/(panel|server)(/|$)',
|
||||
]),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user