1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-15 09:50:06 +00:00

chore(web): commented local endpoints

This commit is contained in:
Saad Jutt
2021-11-10 08:10:57 +05:00
parent c47782eed2
commit 42dde3eded
2 changed files with 24 additions and 19 deletions

View File

@@ -1,25 +1,30 @@
import axios from 'axios'
import React, { useState } from 'react' import React, { useState } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { CssBaseline, Box, TextField, Button } from '@mui/material' import { CssBaseline, Box, TextField, Button } from '@mui/material'
const getAuthCode = async (credentials: any) => { const getAuthCode = async (credentials: any) => {
return fetch('http://localhost:5000/SASjsApi/auth/authorize', { return axios
method: 'POST', .post('/SASjsApi/auth/authorize', {
headers: { method: 'POST',
'Content-Type': 'application/json' headers: {
}, 'Content-Type': 'application/json'
body: JSON.stringify(credentials) },
}).then((data) => data.json()) body: JSON.stringify(credentials)
})
.then((data: any) => data.json())
} }
const getTokens = async (payload: any) => { const getTokens = async (payload: any) => {
return fetch('http://localhost:5000/SASjsApi/auth/token', { return axios
method: 'POST', .post('/SASjsApi/auth/token', {
headers: { method: 'POST',
'Content-Type': 'application/json' headers: {
}, 'Content-Type': 'application/json'
body: JSON.stringify(payload) },
}).then((data) => data.json()) body: JSON.stringify(payload)
})
.then((data: any) => data.json())
} }
const Login = ({ setTokens }: any) => { const Login = ({ setTokens }: any) => {

View File

@@ -43,14 +43,14 @@ export default function useTokens() {
} }
} }
const baseUrl = 'http://localhost:5000' // const baseUrl = 'http://localhost:5000'
const isAbsoluteURLRegex = /^(?:\w+:)\/\// // const isAbsoluteURLRegex = /^(?:\w+:)\/\//
const setAxiosRequestHeader = (accessToken: string) => { const setAxiosRequestHeader = (accessToken: string) => {
axios.interceptors.request.use(function (config: any) { axios.interceptors.request.use(function (config: any) {
if (!isAbsoluteURLRegex.test(config.url)) { // if (!isAbsoluteURLRegex.test(config.url)) {
config.url = baseUrl + config.url // config.url = baseUrl + config.url
} // }
config.headers.Authorization = `Bearer ${accessToken}` config.headers.Authorization = `Bearer ${accessToken}`
return config return config