2025-08-11 23:21:36 +07:00
|
|
|
// vite.config.ts
|
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
import { tanstackRouter } from '@tanstack/router-plugin/vite'
|
|
|
|
|
import tailwindcss from "@tailwindcss/vite"
|
|
|
|
|
import path from 'path'
|
2026-03-29 00:21:31 +07:00
|
|
|
import basicSsl from '@vitejs/plugin-basic-ssl'
|
2025-08-11 23:21:36 +07:00
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
|
|
|
|
|
tanstackRouter({
|
|
|
|
|
target: 'react',
|
|
|
|
|
autoCodeSplitting: true,
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
react(),
|
2026-03-29 00:21:31 +07:00
|
|
|
tailwindcss(),
|
|
|
|
|
basicSsl()
|
2025-08-11 23:21:36 +07:00
|
|
|
// ...,
|
|
|
|
|
],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-03-29 00:21:31 +07:00
|
|
|
server: {
|
|
|
|
|
proxy: {
|
|
|
|
|
'/mesh-api': {
|
|
|
|
|
target: 'https://my-mesh-test.com',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
rewrite: (path) => path.replace(/^\/mesh-api/, ''),
|
|
|
|
|
secure: false, // Bỏ qua lỗi SSL của MeshCentral
|
|
|
|
|
configure: (proxy, options) => {
|
|
|
|
|
proxy.on('proxyRes', (proxyRes) => {
|
|
|
|
|
const setCookie = proxyRes.headers['set-cookie'];
|
|
|
|
|
if (setCookie) {
|
|
|
|
|
// Sửa toàn bộ Cookie trả về: Đổi Lax -> None, thêm Secure
|
|
|
|
|
proxyRes.headers['set-cookie'] = setCookie.map(cookie => {
|
|
|
|
|
// Nếu gặp cookie trống (e30=), ta có thể bỏ qua hoặc giữ nhưng phải ép None
|
|
|
|
|
return cookie
|
|
|
|
|
.replace(/SameSite=Lax/gi, 'SameSite=None')
|
|
|
|
|
.replace(/SameSite=Strict/gi, 'SameSite=None') + '; Secure';
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-08-11 23:21:36 +07:00
|
|
|
})
|