Skip to content

Commit 03bc4f2

Browse files
stubbiclaude
andcommitted
fix: use public URL for all bootstrap API calls
Better Auth's cookie domain and CORS checks require the request URL to match the configured public URL. Using the internal service URL caused 401 errors on invite acceptance because session cookies were scoped to the wrong domain. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e496aaa commit 03bc4f2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

internal/resources/bootstrap.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ SIGNUP_STATUS=$(curl -sS -o /tmp/signup.json -w '%%{http_code}' \
7373
-c "$COOKIE_JAR" -b "$COOKIE_JAR" \
7474
-H "Content-Type: application/json" \
7575
-H "Origin: $SERVER_URL" \
76-
-X POST "$SVC_URL/api/auth/sign-up/email" \
76+
-X POST "$SERVER_URL/api/auth/sign-up/email" \
7777
-d "{\"name\":\"%s\",\"email\":\"$ADMIN_EMAIL\",\"password\":\"$ADMIN_PASSWORD\"}") || true
7878
7979
if echo "$SIGNUP_STATUS" | grep -q '^2'; then
@@ -84,7 +84,7 @@ else
8484
-c "$COOKIE_JAR" -b "$COOKIE_JAR" \
8585
-H "Content-Type: application/json" \
8686
-H "Origin: $SERVER_URL" \
87-
-X POST "$SVC_URL/api/auth/sign-in/email" \
87+
-X POST "$SERVER_URL/api/auth/sign-in/email" \
8888
-d "{\"email\":\"$ADMIN_EMAIL\",\"password\":\"$ADMIN_PASSWORD\"}") || true
8989
if echo "$SIGNIN_STATUS" | grep -q '^2'; then
9090
echo "Signed in as existing admin."
@@ -95,7 +95,7 @@ else
9595
fi
9696
9797
# Step 2: Check if instance is already bootstrapped
98-
HEALTH=$(curl -sS -c "$COOKIE_JAR" -b "$COOKIE_JAR" "$SVC_URL/api/health" 2>/dev/null) || true
98+
HEALTH=$(curl -sS -c "$COOKIE_JAR" -b "$COOKIE_JAR" "$SERVER_URL/api/health" 2>/dev/null) || true
9999
if echo "$HEALTH" | grep -q '"bootstrapStatus":"ready"'; then
100100
echo "Instance already bootstrapped. Nothing to do."
101101
rm -f "$COOKIE_JAR"
@@ -120,7 +120,7 @@ ACCEPT_STATUS=$(curl -sS -o /tmp/accept.json -w '%%{http_code}' \
120120
-c "$COOKIE_JAR" -b "$COOKIE_JAR" \
121121
-H "Content-Type: application/json" \
122122
-H "Origin: $SERVER_URL" \
123-
-X POST "$SVC_URL/api/invites/$INVITE_TOKEN/accept" \
123+
-X POST "$SERVER_URL/api/invites/$INVITE_TOKEN/accept" \
124124
-d '{"requestType":"human"}') || true
125125
126126
if echo "$ACCEPT_STATUS" | grep -q '^2'; then

0 commit comments

Comments
 (0)