removing url from bearer

This commit is contained in:
Cristhian Zanforlin Lousa 2023-08-11 20:37:00 -03:00
commit 35dcdb9e34
2 changed files with 11 additions and 1 deletions

View file

@ -509,6 +509,7 @@ export const URL_EXCLUDED_FROM_ERROR_RETRIES = [
"/api/v1/validate/prompt", "/api/v1/validate/prompt",
"http://localhost:7860/login" "http://localhost:7860/login"
]; ];
export const CONTROL_INPUT_STATE = { export const CONTROL_INPUT_STATE = {
password: "", password: "",
cnfPassword: "", cnfPassword: "",

View file

@ -13,7 +13,7 @@ const api: AxiosInstance = axios.create({
function ApiInterceptor() { function ApiInterceptor() {
const { setErrorData } = useContext(alertContext); const { setErrorData } = useContext(alertContext);
const { accessToken, refreshAccessToken, login, logout } = useContext(AuthContext); const { accessToken, login, logout } = useContext(AuthContext);
const navigate = useNavigate(); const navigate = useNavigate();
useEffect(() => { useEffect(() => {
@ -75,9 +75,18 @@ function ApiInterceptor() {
// Request interceptor to add access token to every request // Request interceptor to add access token to every request
const requestInterceptor = api.interceptors.request.use( const requestInterceptor = api.interceptors.request.use(
(config) => { (config) => {
if (accessToken) { if (accessToken) {
config.headers["Authorization"] = `Bearer ${accessToken}`; config.headers["Authorization"] = `Bearer ${accessToken}`;
} }
if(
config?.url?.includes("https://raw.githubusercontent.com/logspace-ai/langflow_examples/main/examples") ||
config?.url?.includes("https://api.github.com/repos/logspace-ai/langflow_examples/contents/examples"))
{
delete config.headers["Authorization"];
}
return config; return config;
}, },
(error) => { (error) => {