diff --git a/web/src/components/login.tsx b/web/src/components/login.tsx index 0fb4a55..b352eb7 100644 --- a/web/src/components/login.tsx +++ b/web/src/components/login.tsx @@ -1,25 +1,30 @@ +import axios from 'axios' import React, { useState } from 'react' import PropTypes from 'prop-types' import { CssBaseline, Box, TextField, Button } from '@mui/material' const getAuthCode = async (credentials: any) => { - return fetch('http://localhost:5000/SASjsApi/auth/authorize', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(credentials) - }).then((data) => data.json()) + return axios + .post('/SASjsApi/auth/authorize', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(credentials) + }) + .then((data: any) => data.json()) } const getTokens = async (payload: any) => { - return fetch('http://localhost:5000/SASjsApi/auth/token', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(payload) - }).then((data) => data.json()) + return axios + .post('/SASjsApi/auth/token', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(payload) + }) + .then((data: any) => data.json()) } const Login = ({ setTokens }: any) => { diff --git a/web/src/components/useTokens.ts b/web/src/components/useTokens.ts index 33f2480..99f0081 100644 --- a/web/src/components/useTokens.ts +++ b/web/src/components/useTokens.ts @@ -43,14 +43,14 @@ export default function useTokens() { } } -const baseUrl = 'http://localhost:5000' -const isAbsoluteURLRegex = /^(?:\w+:)\/\// +// const baseUrl = 'http://localhost:5000' +// const isAbsoluteURLRegex = /^(?:\w+:)\/\// const setAxiosRequestHeader = (accessToken: string) => { axios.interceptors.request.use(function (config: any) { - if (!isAbsoluteURLRegex.test(config.url)) { - config.url = baseUrl + config.url - } + // if (!isAbsoluteURLRegex.test(config.url)) { + // config.url = baseUrl + config.url + // } config.headers.Authorization = `Bearer ${accessToken}` return config