@authhero/react-admin 0.25.0 → 0.26.0
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/index.tsx +9 -34
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -7,24 +7,12 @@ import { AuthCallback } from "./AuthCallback";
|
|
|
7
7
|
import { DomainSelector } from "./components/DomainSelector";
|
|
8
8
|
import { getSelectedDomainFromStorage } from "./utils/domainUtils";
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
const isLocalDevelopment = window.location.hostname.startsWith("local.");
|
|
12
|
-
const LOCAL_DOMAIN = "localhost:3000";
|
|
13
|
-
|
|
14
|
-
// Check if single domain mode is enabled - skips the domain selector entirely
|
|
15
|
-
const isSingleDomainMode = import.meta.env.VITE_SINGLE_DOMAIN_MODE === "true";
|
|
10
|
+
// If a domain is configured via env, use single-domain mode automatically
|
|
16
11
|
const envDomain = import.meta.env.VITE_AUTH0_DOMAIN;
|
|
17
12
|
|
|
18
13
|
function Root() {
|
|
19
|
-
// In single domain mode, always use the configured domain from env
|
|
20
|
-
const getInitialDomain = () => {
|
|
21
|
-
if (isLocalDevelopment) return LOCAL_DOMAIN;
|
|
22
|
-
if (isSingleDomainMode && envDomain) return envDomain;
|
|
23
|
-
return null;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
14
|
const [selectedDomain, setSelectedDomain] = useState<string | null>(
|
|
27
|
-
|
|
15
|
+
envDomain || null,
|
|
28
16
|
);
|
|
29
17
|
const currentPath = location.pathname;
|
|
30
18
|
const isAuthCallback = currentPath === "/auth-callback";
|
|
@@ -35,10 +23,9 @@ function Root() {
|
|
|
35
23
|
currentPath.startsWith("/tenants/create") ||
|
|
36
24
|
currentPath === "/tenants/";
|
|
37
25
|
|
|
38
|
-
// Load domain from cookies on component mount (
|
|
26
|
+
// Load domain from cookies on component mount (only when no env domain configured)
|
|
39
27
|
useEffect(() => {
|
|
40
|
-
if (
|
|
41
|
-
// For local development or single domain mode, always use the configured domain
|
|
28
|
+
if (envDomain) {
|
|
42
29
|
return;
|
|
43
30
|
}
|
|
44
31
|
const savedDomain = getSelectedDomainFromStorage();
|
|
@@ -58,9 +45,8 @@ function Root() {
|
|
|
58
45
|
);
|
|
59
46
|
}
|
|
60
47
|
|
|
61
|
-
// Show domain selector
|
|
62
|
-
|
|
63
|
-
if (!isLocalDevelopment && !isSingleDomainMode && (isRootPath || !selectedDomain)) {
|
|
48
|
+
// Show domain selector only if no domain is selected
|
|
49
|
+
if (!selectedDomain) {
|
|
64
50
|
return (
|
|
65
51
|
<DomainSelector
|
|
66
52
|
onDomainSelected={(domain) => setSelectedDomain(domain)}
|
|
@@ -69,14 +55,8 @@ function Root() {
|
|
|
69
55
|
);
|
|
70
56
|
}
|
|
71
57
|
|
|
72
|
-
// For
|
|
73
|
-
if (
|
|
74
|
-
window.location.href = "/tenants";
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// For local development on root path, redirect to /tenants
|
|
79
|
-
if (isLocalDevelopment && isRootPath) {
|
|
58
|
+
// For env-configured domain on root path, redirect to /tenants
|
|
59
|
+
if (envDomain && isRootPath) {
|
|
80
60
|
window.location.href = "/tenants";
|
|
81
61
|
return null;
|
|
82
62
|
}
|
|
@@ -106,12 +86,7 @@ function Root() {
|
|
|
106
86
|
);
|
|
107
87
|
}
|
|
108
88
|
|
|
109
|
-
// Fallback to domain selector
|
|
110
|
-
if (isLocalDevelopment) {
|
|
111
|
-
window.location.href = "/tenants";
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
89
|
+
// Fallback to domain selector
|
|
115
90
|
return (
|
|
116
91
|
<DomainSelector
|
|
117
92
|
onDomainSelected={(domain) => setSelectedDomain(domain)}
|