You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

11 lines
490 B

import { proxyRequest } from 'h3'
// 将 /web/api/* 和 /console/api/* 代理到 console 后端服务
// CONSOLE_BACKEND 在 Docker Compose 中通过环境变量注入,本地开发默认 127.0.0.1:8080
export default defineEventHandler(async (event) => {
const path = event.path || ''
if (!path.startsWith('/web/api') && !path.startsWith('/console/api')) return
const backend = process.env.CONSOLE_BACKEND || 'http://127.0.0.1:8080'
await proxyRequest(event, backend + path)
})