Skip to content

Commit

Permalink
fix: Check captcha for only captcha protected routes
Browse files Browse the repository at this point in the history
  • Loading branch information
devadathanmb committed Sep 28, 2024
1 parent 789110d commit 620b45c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api/interceptors/recaptcha.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { InternalCacheRequestConfig } from "axios-cache-interceptor";
import { BASE_URL } from "@/constants/constants";
import { COURSES_URL, PUBLISHED_RESULTS_URL, RESULT_URL } from "@/constants/constants";
import Logger from "@/utils/logger";
import { axios } from "../axios";
import { BypassData, getBypassData } from "../utils/getBypassData";
import { getXToken } from "../utils/getXToken";

const logger = Logger.getLogger("INTERCEPTOR");

const PROTECTED_URLS = [COURSES_URL, RESULT_URL, PUBLISHED_RESULTS_URL];

const recaptchaInterceptor = async (config: InternalCacheRequestConfig) => {
if (config.url?.includes(BASE_URL)) {
if (PROTECTED_URLS.some(url => config.url?.includes(url))) {
// Check if request is already cached, if so don't generate a new key
const key = axios.generateKey(config);
const cached = await axios.storage.get(key);
Expand Down

0 comments on commit 620b45c

Please sign in to comment.