Commit a5657ed
fix(cli): widen better-auth trustedOrigins for preview-mode subdomains
Better-auth's CSRF check uses a glob that does not cross dot-separators,
so the default `http://localhost:*` pattern rejected preview hosts of
the form `<commit>--<pidShort>.localhost:<port>`. The browser sign-up
POST to /api/v1/auth/sign-up/email returned 403 with
'[Better Auth]: Invalid origin: http://...localhost:3100'.
The CLI's auto-registered AuthPlugin now builds the trustedOrigins
allow-list explicitly:
- explicit OS_TRUSTED_ORIGINS (comma-separated) wins
- the configured baseUrl is always added
- in OS_PREVIEW_MODE=1, add `http(s)://*.<base>:<*?>` for every
domain in OS_PREVIEW_BASE_DOMAINS (default
'preview.objectstack.ai,localhost'); loopback bases use http+:*
- dev keeps the legacy `http://localhost:*` for non-preview portals
Verified end-to-end: a preview host now serves /_account/setup, the
sign-up POST succeeds, the user is redirected to /_console/home, and
clicking the Enterprise CRM card renders the lead view with the three
sandbox lead records pulled from the per-(project,commit) memory kernel.
No source change is needed in the AuthPlugin, console, or preview stack.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 0404d30 commit a5657ed
1 file changed
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
598 | 640 | | |
599 | 641 | | |
600 | 642 | | |
601 | 643 | | |
| 644 | + | |
602 | 645 | | |
603 | 646 | | |
604 | 647 | | |
| |||
0 commit comments