fix
This commit is contained in:
+71
-15
@@ -1,5 +1,5 @@
|
||||
import crypto from 'node:crypto'
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import obfuscatorPlugin from 'rollup-plugin-obfuscator'
|
||||
@@ -142,20 +142,76 @@ function apiGuard() {
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [apiGuard(), react(), tailwindcss(), obfuscate(), sri()],
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 3001,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.VITE_API_TARGET ?? 'http://localhost:6000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/health': {
|
||||
target: process.env.VITE_API_TARGET ?? 'http://localhost:6000',
|
||||
changeOrigin: true,
|
||||
function comingSoonHtml() {
|
||||
return `<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex">
|
||||
<meta name="theme-color" content="#fefde7">
|
||||
<title>Toothless' TSS Bot | Coming soon</title>
|
||||
</head>
|
||||
<body style="margin:0;min-width:320px;min-height:100vh;background:#fefde7;color:#000;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Arial,sans-serif;">
|
||||
<main style="min-height:100vh;display:grid;place-items:center;padding:32px;">
|
||||
<section style="width:min(100%,720px);border-left:4px solid #e82517;padding:8px 0 8px 28px;">
|
||||
<p style="margin:0 0 14px;color:#e82517;font-size:13px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;">Toothless' TSS Bot</p>
|
||||
<h1 style="margin:0;color:#000;font-size:clamp(48px,12vw,112px);line-height:.92;font-weight:900;letter-spacing:0;">Coming soon</h1>
|
||||
<p style="margin:24px 0 0;max-width:520px;color:#555;font-size:18px;line-height:1.6;font-weight:600;">TSS analytics are getting tucked away for a little bit. Check back soon.</p>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>`
|
||||
}
|
||||
|
||||
function comingSoonDev(enabled) {
|
||||
return {
|
||||
name: 'coming-soon-dev',
|
||||
configureServer(server) {
|
||||
if (!enabled) return
|
||||
|
||||
server.middlewares.use((req, res, next) => {
|
||||
if (req.url?.startsWith('/api/') || req.url === '/health') {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
const acceptsHtml = String(req.headers.accept || '').includes('text/html')
|
||||
if (!acceptsHtml && req.url !== '/') {
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
res.writeHead(200, {
|
||||
'content-type': 'text/html; charset=utf-8',
|
||||
'cache-control': 'no-store',
|
||||
'x-content-type-options': 'nosniff',
|
||||
})
|
||||
res.end(comingSoonHtml())
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
const comingSoon = String(env.comingsoon || env.COMINGSOON || '').toLowerCase() === 'true'
|
||||
|
||||
return {
|
||||
plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss(), obfuscate(), sri()],
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 3001,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: process.env.VITE_API_TARGET ?? 'http://localhost:6000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/health': {
|
||||
target: process.env.VITE_API_TARGET ?? 'http://localhost:6000',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user