Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): checks for cf error more generally #747

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/deploy-web/src/components/turnstile/Turnstile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FC, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { MdInfo } from "react-icons/md";
import { Button } from "@akashnetwork/ui/components";
import { Turnstile as ReactTurnstile, TurnstileInstance } from "@marsidev/react-turnstile";
import axios, { AxiosError, AxiosHeaders } from "axios";
import axios, { AxiosError } from "axios";
import { motion } from "framer-motion";
import { firstValueFrom, Subject } from "rxjs";

Expand All @@ -25,9 +25,9 @@ export const Turnstile: FC = () => {
const interceptorId = managedWalletHttpService.interceptors.response.use(
response => response,
async (error: AxiosError) => {
const headers = error.response?.headers;
const request = error?.request;

if (headers instanceof AxiosHeaders && headers.get("cf-mitigated") === "challenge" && turnstileRef.current) {
if (request?.status === 0 && turnstileRef.current) {
turnstileRef.current?.render();
turnstileRef.current.execute();
const response = await Promise.race([turnstileRef.current.getResponsePromise(), firstValueFrom(dismissedSubject.current.asObservable())]);
Expand Down