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 [oauthLoading, setOauthLoading] = useState<string | null>(null);
|
||||
|
||||
async function handleOAuth(providerId: string) {
|
||||
function handleOAuth(providerId: string) {
|
||||
if (oauthLoading) return;
|
||||
setOauthLoading(providerId);
|
||||
try {
|
||||
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);
|
||||
}
|
||||
window.location.href = `${base}/api/v1/oauth/${providerId}?redirectUrl=${redirectUrl}`;
|
||||
}
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
|
||||
Reference in New Issue
Block a user