Skip to content

Commit

Permalink
MAT-7204 add intercept for waf
Browse files Browse the repository at this point in the history
  • Loading branch information
ethankaplan committed Jun 17, 2024
1 parent 1e25817 commit f5a6055
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/api/useCqlLibraryServiceApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useServiceConfig from "./useServiceConfig";
import { ServiceConfig } from "./ServiceContext";
import { CqlLibrary } from "@madie/madie-models";
import useOktaTokens from "../hooks/useOktaTokens";

import { wafIntercept } from "@madie/madie-util";
export class CqlLibraryServiceApi {
constructor(private baseUrl: string, private getAccessToken: () => string) {}

Expand Down Expand Up @@ -101,6 +101,10 @@ export class CqlLibraryServiceApi {
}
}

axios.interceptors.response.use((response) => {
return response;
}, wafIntercept);

export default function useCqlLibraryServiceApi() {
const serviceConfig: ServiceConfig = useServiceConfig();
const { getAccessToken } = useOktaTokens();
Expand Down
6 changes: 5 additions & 1 deletion src/components/config/useGetServiceConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";
import { useEffect, useState } from "react";

import { wafIntercept } from "@madie/madie-util";
export interface OktaConfig {
baseUrl: string;
issuer: string;
Expand All @@ -23,6 +23,10 @@ export interface ServiceConfig {
};
}

axios.interceptors.response.use((response) => {
return response;
}, wafIntercept);

const useGetServiceConfig = () => {
const [config, setConfig] = useState<ServiceConfig | null>(null);
const [error, setError] = useState<Error | null>(null);
Expand Down
2 changes: 2 additions & 0 deletions src/types/madie-madie-util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ declare module "@madie/madie-util" {
draft?: boolean
): boolean;

export function wafIntercept(): void;

export const bootstrap: LifeCycleFn<void>;
export const mount: LifeCycleFn<void>;
export const unmount: LifeCycleFn<void>;
Expand Down

0 comments on commit f5a6055

Please sign in to comment.