New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forward /admin
to admin container
#79
Comments
vite.config.js import { fileURLToPath, URL } from "url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
const {
BACKEND_PROTOCOL,
BACKEND_HOST,
BACKEND_PORT,
ADMIN_PROTOCOL,
ADMIN_HOST,
ADMIN_PORT
} = process.env = Object.assign({
BACKEND_PROTOCOL: "http",
BACKEND_HOST: "127.0.0.1",
BACKEND_PORT: "8080",
ADMIN_PROTOCOL: "http",
ADMIN_HOST: "127.0.0.1",
ADMIN_PORT: "3001"
}, process.env);
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue()
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
},
server: {
host: "0.0.0.0",
proxy: {
"/api": {
target: `${BACKEND_PROTOCOL}://${BACKEND_HOST}:${BACKEND_PORT}`,
ws: true,
xfwd: true
},
"/auth": {
target: `${BACKEND_PROTOCOL}://${BACKEND_HOST}:${BACKEND_PORT}`,
xfwd: true
},
// does not work, loads every time the user ui, not admin ui
// https://stackoverflow.com/questions/76884970/vite-proxy-forward-admin-to-other-vue-vite-app
// somewhere there is a issue open on the vite repo that tries to fix that issue
/*
"/admin": {
target: `${ADMIN_PROTOCOL}://${ADMIN_HOST}:${ADMIN_PORT}`,
xfwd: true,
changeOrigin: true,
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);
});
},
rewrite: (path) => {
console.log("/admin", path, "replacE:", path.replace(/^\/admin/, ''));
return path.replace(/^\/admin/, '')
}
}
*/
}
},
build: {
outDir: "build",
emptyOutDir: true
},
clearScreen: false
});
`` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: