2024-10-22 14:45:57 +00:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
import react from "@vitejs/plugin-react";
|
2024-10-22 13:27:48 +00:00
|
|
|
|
2024-10-22 14:45:57 +00:00
|
|
|
const BASE_URL = "/twittok:tok:sortugdev.os";
|
|
|
|
const COOKIE_PROCESS_ID = "cookies:tok:sortugdev.os";
|
|
|
|
const PROXY_PROCESS_ID = "proxy:tok:sortugdev.os";
|
2024-10-22 13:27:48 +00:00
|
|
|
|
|
|
|
// This is the proxy URL, it must match the node you are developing against
|
2024-10-22 14:45:57 +00:00
|
|
|
const PROXY_URL = (
|
|
|
|
process.env.VITE_NODE_URL || "http://127.0.0.1:8080"
|
|
|
|
).replace("localhost", "127.0.0.1");
|
2024-10-22 13:27:48 +00:00
|
|
|
|
2024-10-22 14:45:57 +00:00
|
|
|
console.log("process.env.VITE_NODE_URL", process.env.VITE_NODE_URL, PROXY_URL);
|
2024-10-22 13:27:48 +00:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
plugins: [react()],
|
|
|
|
base: BASE_URL,
|
|
|
|
build: {
|
|
|
|
rollupOptions: {
|
2024-10-22 14:45:57 +00:00
|
|
|
external: ["/our.js"],
|
|
|
|
},
|
2024-10-22 13:27:48 +00:00
|
|
|
},
|
|
|
|
server: {
|
|
|
|
open: true,
|
|
|
|
proxy: {
|
2024-10-22 14:45:57 +00:00
|
|
|
"^.*": {
|
2024-10-22 13:27:48 +00:00
|
|
|
target: PROXY_URL,
|
|
|
|
changeOrigin: true,
|
|
|
|
},
|
2024-10-22 14:45:57 +00:00
|
|
|
// "/our": {
|
|
|
|
// target: PROXY_URL,
|
|
|
|
// changeOrigin: true,
|
|
|
|
// },
|
|
|
|
// [`^/${COOKIE_PROCESS_ID}/api.*`]: {
|
|
|
|
// target: PROXY_URL,
|
|
|
|
// changeOrigin: true,
|
|
|
|
// rewrite: (path) => path.replace(COOKIE_PROCESS_ID, ""),
|
|
|
|
// },
|
|
|
|
// [`/${PROXY_PROCESS_ID}`]: {
|
|
|
|
// target: PROXY_URL,
|
|
|
|
// changeOrigin: true,
|
|
|
|
// rewrite: (path) => path.replace(PROXY_PROCESS_ID, ""),
|
|
|
|
// },
|
|
|
|
// [`${BASE_URL}/our.js`]: {
|
|
|
|
// target: PROXY_URL,
|
|
|
|
// changeOrigin: true,
|
|
|
|
// rewrite: (path) => path.replace(BASE_URL, ""),
|
|
|
|
// },
|
|
|
|
// // This route will match all other HTTP requests to the backend
|
|
|
|
// [`^${BASE_URL}/(?!(@vite/client|src/.*|node_modules/.*|@react-refresh|$))`]:
|
|
|
|
// {
|
|
|
|
// target: PROXY_URL,
|
|
|
|
// changeOrigin: true,
|
|
|
|
// },
|
2024-10-22 13:27:48 +00:00
|
|
|
// '/example': {
|
|
|
|
// target: PROXY_URL,
|
|
|
|
// changeOrigin: true,
|
|
|
|
// rewrite: (path) => path.replace(BASE_URL, ''),
|
|
|
|
// // This is only for debugging purposes
|
|
|
|
// configure: (proxy, _options) => {
|
|
|
|
// proxy.on('error', (err, _req, _res) => {
|
|
|
|
// console.log('proxy error', err);
|
|
|
|
// });
|
|
|
|
// proxy.on('proxyReq', (proxyReq, req, _res) => {
|
|
|
|
// console.log('Sending Request to the Target:', req.method, req.url);
|
|
|
|
// });
|
|
|
|
// proxy.on('proxyRes', (proxyRes, req, _res) => {
|
|
|
|
// console.log('Received Response from the Target:', proxyRes.statusCode, req.url);
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// },
|
2024-10-22 14:45:57 +00:00
|
|
|
},
|
|
|
|
},
|
2024-10-22 13:27:48 +00:00
|
|
|
});
|