mango-cms 0.2.49 → 0.2.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +31 -5
- package/default/package.json +1 -1
- package/default/vite.config.js +1 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -834,11 +834,36 @@ const proxyCmd = program
|
|
|
834
834
|
|
|
835
835
|
// Start the proxy server as a detached background process
|
|
836
836
|
const proxyScript = path.join(__dirname, 'lib/dev-proxy.js');
|
|
837
|
-
const
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
837
|
+
const logPath = path.join(process.cwd(), '.mango-proxy.log');
|
|
838
|
+
|
|
839
|
+
// Use shell to redirect output to a log file and background the process
|
|
840
|
+
// This keeps sudo in the current TTY so the password prompt works
|
|
841
|
+
execSync(
|
|
842
|
+
`sudo node "${proxyScript}" ${frontDomain} ${apiDomain} ${frontendPort} ${backendPort} "${pidPath}" > "${logPath}" 2>&1 &`,
|
|
843
|
+
{ stdio: 'inherit', shell: true }
|
|
844
|
+
);
|
|
845
|
+
|
|
846
|
+
// Wait briefly for the proxy to start and write its PID
|
|
847
|
+
let started = false;
|
|
848
|
+
for (let i = 0; i < 10; i++) {
|
|
849
|
+
await new Promise(r => setTimeout(r, 300));
|
|
850
|
+
if (fs.existsSync(pidPath)) {
|
|
851
|
+
const pid = fs.readFileSync(pidPath, 'utf8').trim();
|
|
852
|
+
try {
|
|
853
|
+
execSync(`kill -0 ${pid} 2>/dev/null`);
|
|
854
|
+
started = true;
|
|
855
|
+
break;
|
|
856
|
+
} catch (e) { /* not running yet */ }
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
if (!started) {
|
|
861
|
+
console.error('\nFailed to start proxy server.');
|
|
862
|
+
if (fs.existsSync(logPath)) {
|
|
863
|
+
console.error('Log output:\n' + fs.readFileSync(logPath, 'utf8'));
|
|
864
|
+
}
|
|
865
|
+
process.exit(1);
|
|
866
|
+
}
|
|
842
867
|
|
|
843
868
|
console.log(`
|
|
844
869
|
Mango Dev Proxy started.
|
|
@@ -850,6 +875,7 @@ Start your dev servers with proxy support:
|
|
|
850
875
|
mango start (backend on port ${backendPort})
|
|
851
876
|
VITE_DEV_PROXY=${apiDomain} mango ui dev (frontend on port ${frontendPort})
|
|
852
877
|
|
|
878
|
+
Proxy log: ${logPath}
|
|
853
879
|
To stop: mango proxy stop
|
|
854
880
|
`);
|
|
855
881
|
} else if (action === 'stop') {
|
package/default/package.json
CHANGED
package/default/vite.config.js
CHANGED
|
@@ -57,6 +57,7 @@ export default defineConfig({
|
|
|
57
57
|
],
|
|
58
58
|
server: {
|
|
59
59
|
host: '0.0.0.0',
|
|
60
|
+
allowedHosts: ['.mango'],
|
|
60
61
|
// When running behind mango proxy, configure HMR to use the proxy domain
|
|
61
62
|
// VITE_DEV_PROXY is set to api.{slug}.mango; derive frontend domain by stripping "api." prefix
|
|
62
63
|
...(process.env.VITE_DEV_PROXY?.startsWith('api.') ? {
|