83 lines
2.2 KiB
TypeScript
83 lines
2.2 KiB
TypeScript
import tailwindcss from "@tailwindcss/vite"
|
||
import react from "@vitejs/plugin-react"
|
||
import path from "path"
|
||
import { defineConfig } from "vite"
|
||
|
||
// https://vite.dev/config/
|
||
export default defineConfig({
|
||
plugins: [react(), tailwindcss()],
|
||
resolve: {
|
||
alias: {
|
||
"@": path.resolve(__dirname, "./src"),
|
||
},
|
||
},
|
||
server: {
|
||
proxy: {
|
||
"/api": "http://192.168.3.6:5000",
|
||
"/article": "http://192.168.3.6:5000",
|
||
"/user/UserScore": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/user": "http://192.168.3.6:5000",
|
||
"/product": {
|
||
target: "http://192.168.3.6:5000",
|
||
bypass(req) {
|
||
if (req.headers?.accept?.includes("text/html")) {
|
||
// 仅前端 SPA 路由回退 index.html;续费等后端老页面(rebuyindex/rebuy)
|
||
// 需要直达后端渲染
|
||
const pathname = new URL(req.url ?? "", "http://localhost").pathname
|
||
const spaPaths = [
|
||
"/product",
|
||
"/product/buy",
|
||
"/product/buy-static",
|
||
"/product/http",
|
||
"/product/routeros",
|
||
]
|
||
if (spaPaths.includes(pathname)) {
|
||
return "/index.html"
|
||
}
|
||
}
|
||
},
|
||
},
|
||
"/script": "https://php-api.juip.com",
|
||
"/jinyou": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/http": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/agent": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/realname": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/tencent": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/order": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/ros": {
|
||
target: "https://php-api.juip.com",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
},
|
||
},
|
||
})
|