@growthub/cli 0.3.39 → 0.3.40
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/assets/worker-kits/growthub-open-higgsfield-studio-v1/QUICKSTART.md +11 -1
- package/assets/worker-kits/growthub-open-higgsfield-studio-v1/kit.json +2 -0
- package/assets/worker-kits/growthub-open-higgsfield-studio-v1/runtime-assumptions.md +37 -0
- package/assets/worker-kits/growthub-open-higgsfield-studio-v1/setup/clone-fork.sh +13 -0
- package/assets/worker-kits/growthub-open-higgsfield-studio-v1/setup/patch-cors-proxy.sh +139 -0
- package/package.json +1 -1
|
@@ -50,7 +50,17 @@ Checks for `node`, `npm`, `git`, and `ffmpeg`. All four are required for local-f
|
|
|
50
50
|
bash setup/clone-fork.sh
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
Clones the Open Higgsfield AI repo to `~/open-higgsfield-ai`, installs dependencies, and starts the dev server at `http://localhost:3001`.
|
|
53
|
+
Clones the Open Higgsfield AI repo to `~/open-higgsfield-ai`, installs dependencies, **automatically applies the CORS proxy patch** (see `setup/patch-cors-proxy.sh`), and starts the dev server at `http://localhost:3001`.
|
|
54
|
+
|
|
55
|
+
The CORS patch is required — the upstream repo calls `api.muapi.ai` directly from the browser, which modern browsers block. The patch routes all API calls through the local Next.js server instead.
|
|
56
|
+
|
|
57
|
+
Skip this step if you are using browser-hosted or desktop-app mode.
|
|
58
|
+
|
|
59
|
+
**Already cloned but hitting CORS errors?** Run the patch standalone:
|
|
60
|
+
```bash
|
|
61
|
+
bash setup/patch-cors-proxy.sh
|
|
62
|
+
```
|
|
63
|
+
Then restart your dev server.
|
|
54
64
|
|
|
55
65
|
---
|
|
56
66
|
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"brands/growthub/brand-kit.md",
|
|
34
34
|
"brands/NEW-CLIENT.md",
|
|
35
35
|
"setup/clone-fork.sh",
|
|
36
|
+
"setup/patch-cors-proxy.sh",
|
|
36
37
|
"setup/verify-env.mjs",
|
|
37
38
|
"setup/check-deps.sh",
|
|
38
39
|
"output/README.md",
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
"brands/growthub/brand-kit.md",
|
|
80
81
|
"brands/NEW-CLIENT.md",
|
|
81
82
|
"setup/clone-fork.sh",
|
|
83
|
+
"setup/patch-cors-proxy.sh",
|
|
82
84
|
"setup/verify-env.mjs",
|
|
83
85
|
"setup/check-deps.sh",
|
|
84
86
|
"output/README.md",
|
|
@@ -34,6 +34,43 @@ If the local fork differs, the fork wins.
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
+
## KNOWN FORK ISSUE — CORS POLICY (local-fork mode)
|
|
38
|
+
|
|
39
|
+
**Status:** Fixed. Patch is applied automatically by `setup/clone-fork.sh`.
|
|
40
|
+
|
|
41
|
+
**Root cause:** The upstream repo hardcodes `const BASE_URL = 'https://api.muapi.ai'` in
|
|
42
|
+
`packages/studio/src/muapi.js`. All browser fetch/XHR calls go directly to the external
|
|
43
|
+
API. `api.muapi.ai` does not return `Access-Control-Allow-Origin` headers, so every call
|
|
44
|
+
from `localhost:3001` is blocked by the browser's CORS policy.
|
|
45
|
+
|
|
46
|
+
**Errors you will see without the patch:**
|
|
47
|
+
```
|
|
48
|
+
Access to fetch at 'https://api.muapi.ai/api/v1/account/balance'
|
|
49
|
+
from origin 'http://localhost:3001' has been blocked by CORS policy:
|
|
50
|
+
No 'Access-Control-Allow-Origin' header is present on the requested resource.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**The fix:**
|
|
54
|
+
1. `next.config.mjs` — rewrites `/muapi-proxy/:path*` → `https://api.muapi.ai/:path*` server-side
|
|
55
|
+
2. `packages/studio/src/muapi.js` — `BASE_URL` changed to `'/muapi-proxy'`
|
|
56
|
+
|
|
57
|
+
All browser calls now hit `localhost:3001/muapi-proxy/...` (same origin, no CORS).
|
|
58
|
+
Next.js proxies them to `api.muapi.ai` from the server where CORS does not apply.
|
|
59
|
+
|
|
60
|
+
**To apply manually if not already patched:**
|
|
61
|
+
```bash
|
|
62
|
+
bash setup/patch-cors-proxy.sh [path-to-fork]
|
|
63
|
+
# defaults to ~/open-higgsfield-ai
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Affected functions in muapi.js:**
|
|
67
|
+
- `getUserBalance` — `/api/v1/account/balance`
|
|
68
|
+
- `submitAndPoll` — `/api/v1/${endpoint}`
|
|
69
|
+
- `pollForResult` — `/api/v1/predictions/${requestId}/result`
|
|
70
|
+
- `uploadFile` (XHR) — `/api/v1/upload_file`
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
37
74
|
## EXECUTION SURFACES
|
|
38
75
|
|
|
39
76
|
### Local fork
|
|
@@ -20,6 +20,19 @@ cd "$FORK_DIR"
|
|
|
20
20
|
echo "Installing dependencies..."
|
|
21
21
|
npm install
|
|
22
22
|
|
|
23
|
+
echo ""
|
|
24
|
+
echo "Applying CORS proxy patch..."
|
|
25
|
+
# The upstream repo calls api.muapi.ai directly from the browser, which is blocked
|
|
26
|
+
# by CORS policy. This patch routes all API calls through the Next.js server.
|
|
27
|
+
# See setup/patch-cors-proxy.sh for full explanation.
|
|
28
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
29
|
+
if [ -f "$SCRIPT_DIR/patch-cors-proxy.sh" ]; then
|
|
30
|
+
bash "$SCRIPT_DIR/patch-cors-proxy.sh" "$FORK_DIR"
|
|
31
|
+
else
|
|
32
|
+
echo "WARNING: patch-cors-proxy.sh not found — skipping CORS patch."
|
|
33
|
+
echo "You may hit CORS errors when the studio calls api.muapi.ai from the browser."
|
|
34
|
+
fi
|
|
35
|
+
|
|
23
36
|
echo ""
|
|
24
37
|
echo "Starting dev server on http://localhost:$PORT"
|
|
25
38
|
echo "Press Ctrl+C to stop."
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# patch-cors-proxy.sh — Apply Next.js CORS proxy patch to the Open Higgsfield AI local fork
|
|
3
|
+
#
|
|
4
|
+
# WHY THIS EXISTS
|
|
5
|
+
# ---------------
|
|
6
|
+
# The upstream repo calls api.muapi.ai directly from the browser (BASE_URL in muapi.js).
|
|
7
|
+
# api.muapi.ai does not return Access-Control-Allow-Origin headers, so every browser
|
|
8
|
+
# request from localhost:3001 is blocked by CORS policy.
|
|
9
|
+
#
|
|
10
|
+
# THE FIX
|
|
11
|
+
# -------
|
|
12
|
+
# 1. next.config.mjs — adds a rewrites() block:
|
|
13
|
+
# /muapi-proxy/:path* → https://api.muapi.ai/:path* (server-side, no CORS)
|
|
14
|
+
#
|
|
15
|
+
# 2. packages/studio/src/muapi.js — changes BASE_URL:
|
|
16
|
+
# 'https://api.muapi.ai' → '/muapi-proxy'
|
|
17
|
+
#
|
|
18
|
+
# All fetch/XHR calls now hit the local Next.js server which proxies them server-side.
|
|
19
|
+
# No browser cross-origin request is made. CORS policy never fires.
|
|
20
|
+
#
|
|
21
|
+
# USAGE
|
|
22
|
+
# -----
|
|
23
|
+
# bash setup/patch-cors-proxy.sh [path-to-fork]
|
|
24
|
+
#
|
|
25
|
+
# Defaults to ~/open-higgsfield-ai if no path given.
|
|
26
|
+
# Safe to run multiple times — idempotent.
|
|
27
|
+
|
|
28
|
+
set -e
|
|
29
|
+
|
|
30
|
+
FORK_DIR="${1:-$HOME/open-higgsfield-ai}"
|
|
31
|
+
NEXT_CONFIG="$FORK_DIR/next.config.mjs"
|
|
32
|
+
MUAPI_JS="$FORK_DIR/packages/studio/src/muapi.js"
|
|
33
|
+
|
|
34
|
+
echo ""
|
|
35
|
+
echo "=== CORS Proxy Patch ==="
|
|
36
|
+
echo "Fork: $FORK_DIR"
|
|
37
|
+
echo ""
|
|
38
|
+
|
|
39
|
+
# ── Guard: fork must exist ──────────────────────────────────────────────────
|
|
40
|
+
if [ ! -d "$FORK_DIR" ]; then
|
|
41
|
+
echo "ERROR: Fork not found at $FORK_DIR"
|
|
42
|
+
echo "Run setup/clone-fork.sh first."
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
if [ ! -f "$NEXT_CONFIG" ]; then
|
|
47
|
+
echo "ERROR: next.config.mjs not found at $NEXT_CONFIG"
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if [ ! -f "$MUAPI_JS" ]; then
|
|
52
|
+
echo "ERROR: muapi.js not found at $MUAPI_JS"
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# ── Idempotency check ───────────────────────────────────────────────────────
|
|
57
|
+
if grep -q "muapi-proxy" "$NEXT_CONFIG" 2>/dev/null; then
|
|
58
|
+
echo "✓ next.config.mjs already patched — skipping."
|
|
59
|
+
NEXT_DONE=1
|
|
60
|
+
else
|
|
61
|
+
NEXT_DONE=0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
if grep -q "muapi-proxy" "$MUAPI_JS" 2>/dev/null; then
|
|
65
|
+
echo "✓ muapi.js already patched — skipping."
|
|
66
|
+
MUAPI_DONE=1
|
|
67
|
+
else
|
|
68
|
+
MUAPI_DONE=0
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
if [ "$NEXT_DONE" -eq 1 ] && [ "$MUAPI_DONE" -eq 1 ]; then
|
|
72
|
+
echo ""
|
|
73
|
+
echo "Both files already patched. Nothing to do."
|
|
74
|
+
exit 0
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
# ── Backup originals ────────────────────────────────────────────────────────
|
|
78
|
+
if [ "$NEXT_DONE" -eq 0 ]; then
|
|
79
|
+
cp "$NEXT_CONFIG" "$NEXT_CONFIG.orig"
|
|
80
|
+
fi
|
|
81
|
+
if [ "$MUAPI_DONE" -eq 0 ]; then
|
|
82
|
+
cp "$MUAPI_JS" "$MUAPI_JS.orig"
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# ── Patch next.config.mjs ───────────────────────────────────────────────────
|
|
86
|
+
if [ "$NEXT_DONE" -eq 0 ]; then
|
|
87
|
+
cat > "$NEXT_CONFIG" << 'NEXTEOF'
|
|
88
|
+
/** @type {import('next').NextConfig} */
|
|
89
|
+
const nextConfig = {
|
|
90
|
+
transpilePackages: ['studio'],
|
|
91
|
+
|
|
92
|
+
// CORS proxy — forward all Muapi API calls through the Next.js server so
|
|
93
|
+
// the browser never makes cross-origin requests to api.muapi.ai directly.
|
|
94
|
+
// muapi.js uses BASE_URL = '/muapi-proxy', so every fetch/XHR hits
|
|
95
|
+
// /muapi-proxy/api/v1/... which Next.js rewrites to api.muapi.ai server-side.
|
|
96
|
+
async rewrites() {
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
source: '/muapi-proxy/:path*',
|
|
100
|
+
destination: 'https://api.muapi.ai/:path*',
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default nextConfig;
|
|
107
|
+
NEXTEOF
|
|
108
|
+
echo "✓ next.config.mjs patched — added /muapi-proxy rewrites()"
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# ── Patch muapi.js ──────────────────────────────────────────────────────────
|
|
112
|
+
if [ "$MUAPI_DONE" -eq 0 ]; then
|
|
113
|
+
# Replace the BASE_URL line only (targeted sed, not full file rewrite)
|
|
114
|
+
sed -i.bak \
|
|
115
|
+
"s|const BASE_URL = 'https://api.muapi.ai';|// Proxy through Next.js to avoid CORS. All calls route through /muapi-proxy/:path*\n// which next.config.mjs rewrites to api.muapi.ai server-side — no CORS headers needed.\nconst BASE_URL = '/muapi-proxy';|" \
|
|
116
|
+
"$MUAPI_JS"
|
|
117
|
+
# Remove sed backup (we already made our own)
|
|
118
|
+
rm -f "$MUAPI_JS.bak"
|
|
119
|
+
echo "✓ muapi.js patched — BASE_URL changed to '/muapi-proxy'"
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
# ── Verify ───────────────────────────────────────────────────────────────────
|
|
123
|
+
echo ""
|
|
124
|
+
echo "Verifying patch..."
|
|
125
|
+
|
|
126
|
+
if grep -q "muapi-proxy" "$NEXT_CONFIG" && grep -q "muapi-proxy" "$MUAPI_JS"; then
|
|
127
|
+
echo "✓ Patch verified. Both files updated correctly."
|
|
128
|
+
else
|
|
129
|
+
echo "ERROR: Patch verification failed. Check the files manually."
|
|
130
|
+
echo " $NEXT_CONFIG"
|
|
131
|
+
echo " $MUAPI_JS"
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
echo ""
|
|
136
|
+
echo "CORS proxy patch complete."
|
|
137
|
+
echo "Restart the dev server to pick up next.config.mjs changes:"
|
|
138
|
+
echo " npm run dev -- --port 3001"
|
|
139
|
+
echo ""
|