fix: OAuth — window.location.href direct, no cross-origin fetch (CORS)
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 28s
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 28s
This commit is contained in:
@@ -24,18 +24,10 @@ export default function LoginPage() {
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [oauthLoading, setOauthLoading] = useState<string | null>(null);
|
const [oauthLoading, setOauthLoading] = useState<string | null>(null);
|
||||||
|
|
||||||
async function handleOAuth(providerId: string) {
|
function handleOAuth(providerId: string) {
|
||||||
if (oauthLoading) return;
|
if (oauthLoading) return;
|
||||||
setOauthLoading(providerId);
|
setOauthLoading(providerId);
|
||||||
try {
|
window.location.href = `${base}/api/v1/oauth/${providerId}?redirectUrl=${redirectUrl}`;
|
||||||
const res = await fetch(`${base}/api/v1/oauth/${providerId}?redirectUrl=${redirectUrl}`);
|
|
||||||
const data = await res.json() as { success: boolean; data?: { authUrl?: string } };
|
|
||||||
if (data.data?.authUrl) {
|
|
||||||
window.location.href = data.data.authUrl;
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
setOauthLoading(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent) {
|
async function handleSubmit(e: React.FormEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user