You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When resetting the database using `init_db.py`, `reset_db.py`, or `scripts/reset_db.sh`, the Better Auth tables were not being created, causing "Failed to sign up" errors.
5
+
6
+
## Root Cause
7
+
The database initialization scripts only loaded `migrations/schema.sql`, which contains the main application tables (students, cards, accounts, etc.) but not the Better Auth tables (user, session, account, verification).
8
+
9
+
## Solution Applied
10
+
Updated all database initialization scripts to automatically include Better Auth schema:
Copy file name to clipboardExpand all lines: docs/troubleshooting.md
+42-14Lines changed: 42 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,23 +150,27 @@ pnpm install
150
150
151
151
**Solutions**:
152
152
153
-
1.**Verify Code in Source**:
153
+
1.**Check Environment Variable**:
154
154
155
-
Check `web-next/app/(auth)/signup/page.tsx`:
156
-
```typescript
157
-
constSIGNUP_CODE="12345678"; // Current code
155
+
Verify the `SIGNUP_CODE` is set in `web-next/.env.local`:
156
+
```env
157
+
SIGNUP_CODE=your_code_here
158
158
```
159
-
160
-
2.**Check Environment Variable**:
161
159
162
-
If using env var, verify `.env.local`:
163
-
```env
164
-
NEXT_PUBLIC_SIGNUP_CODE=your_code
160
+
Note: Do NOT use quotes around the value (use `SIGNUP_CODE=abc123` not `SIGNUP_CODE="abc123"`)
161
+
162
+
2.**Restart Server**: After changing `.env.local`, restart the server:
163
+
```bash
164
+
cd web-next
165
+
# Stop the server (Ctrl+C), then:
166
+
pnpm dev
167
+
# Or in production:
168
+
sudo systemctl restart stuco-web
165
169
```
166
170
167
-
3.**Restart Server**: After changing code, restart dev server
171
+
3.**Verify Code Has No Spaces**: Ensure the code has no leading/trailing spaces
168
172
169
-
4.**No Spaces**: Ensure code has no leading/trailing spaces
173
+
4.**Check Server Logs**: Look for "SIGNUP_CODE environment variable is not set" errors
170
174
171
175
### "CORS error" or "Origin not allowed"
172
176
@@ -176,13 +180,37 @@ pnpm install
176
180
2.**Check trustedOrigins**: In `web-next/lib/auth.ts`
177
181
3.**Browser Console**: Check exact error message
178
182
183
+
### "Failed to sign up" Error
184
+
185
+
**Problem**: Signup code is accepted but account creation fails.
186
+
187
+
**Cause**: Better Auth database tables are missing (usually after a database reset).
188
+
189
+
**Solution**:
190
+
191
+
Since v2.0+, Better Auth tables are automatically created by `init_db.py` and reset scripts. If you're using an older database or manually reset it, run:
0 commit comments