33 lines
846 B
TypeScript
33 lines
846 B
TypeScript
import path from "path"
|
|
import react from "@vitejs/plugin-react"
|
|
import { defineConfig, loadEnv } from "vite"
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
const apiKey = env.VITE_UPTIME_API_KEY
|
|
|
|
return {
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
server: {
|
|
port: 4444,
|
|
proxy: {
|
|
'/api/metrics': {
|
|
target: 'https://uptime.kent.pw',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
configure: (proxy, _options) => {
|
|
proxy.on('proxyReq', (proxyReq, _req, _res) => {
|
|
proxyReq.setHeader('Authorization', `Basic ${Buffer.from(':' + apiKey).toString('base64')}`)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|