mirror of
https://github.com/azaion/ui.git
synced 2026-04-22 23:16:35 +00:00
add admin part
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
|
||||
module.exports = function(app) {
|
||||
// Get API base from environment variable or use default
|
||||
const apiBase = process.env.REACT_APP_API_BASE || 'https://api.azaion.com';
|
||||
|
||||
console.log(`[proxy] /proxy -> ${apiBase}`);
|
||||
|
||||
// Proxy /proxy requests to the Azaion API
|
||||
app.use(
|
||||
'/proxy',
|
||||
createProxyMiddleware({
|
||||
target: apiBase,
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/proxy': '', // Remove /proxy prefix when forwarding
|
||||
},
|
||||
onProxyReq: (proxyReq) => {
|
||||
// Ensure JSON content-type is kept if present
|
||||
if (!proxyReq.getHeader('content-type')) {
|
||||
proxyReq.setHeader('content-type', 'application/json');
|
||||
}
|
||||
},
|
||||
logLevel: 'debug', // Enable logging for debugging
|
||||
})
|
||||
);
|
||||
|
||||
// Add server info endpoint so UI can auto-detect proxy status
|
||||
app.get('/__server-info', (req, res) => {
|
||||
res.json({
|
||||
proxyEnabled: true,
|
||||
apiBase: apiBase
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user