mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-18 21:44:07 +01:00
Set baseURL variable
This commit is contained in:
parent
58bfb0edb6
commit
6ac8c65de7
@ -16,6 +16,8 @@ import Dashboard from "./components/dashboard/dashboard";
|
||||
|
||||
import { useAuth } from "./hooks/AuthHooks";
|
||||
|
||||
const baseURL = import.meta.env.VITE_BASE_URL;
|
||||
|
||||
const App = () => {
|
||||
const { isAuthenticated, setIsAuthenticated } = useAuth();
|
||||
|
||||
@ -27,7 +29,7 @@ const App = () => {
|
||||
};
|
||||
|
||||
await axios
|
||||
.post("http://127.0.0.1:8000/api/auth/status/", data, {
|
||||
.post(`${baseURL}auth/status/`, data, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + localStorage.getItem("access_token"),
|
||||
},
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import axios from "axios";
|
||||
import axiosInstance from "./AxiosConfig";
|
||||
|
||||
const baseURL = import.meta.env.VITE_BASE_URL;
|
||||
|
||||
// Function for user login
|
||||
const apiUserLogin = (data) => {
|
||||
return axiosInstance
|
||||
@ -26,7 +28,7 @@ const apiUserLogout = () => {
|
||||
// Function for Google login
|
||||
const googleLogin = async (token) => {
|
||||
axios.defaults.withCredentials = true;
|
||||
let res = await axios.post("http://localhost:8000/api/auth/google/", {
|
||||
let res = await axios.post(`${baseURL}auth/google/`, {
|
||||
code: token,
|
||||
});
|
||||
// console.log('service google login res: ', res);
|
||||
@ -49,7 +51,7 @@ const getGreeting = () => {
|
||||
const createUser = async (formData) => {
|
||||
try {
|
||||
axios.defaults.withCredentials = true;
|
||||
const response = axios.post("http://localhost:8000/api/user/create/", formData);
|
||||
const response = axios.post(`${baseURL}user/create/`, formData);
|
||||
// const response = await axiosInstance.post('/user/create/', formData);
|
||||
return response.data;
|
||||
} catch (e) {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import axios from "axios";
|
||||
import { redirect } from "react-router-dom";
|
||||
|
||||
const baseURL = import.meta.env.VITE_BASE_URL;
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: "http://127.0.0.1:8000/api/",
|
||||
baseURL: baseURL,
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
Authorization: "Bearer " + localStorage.getItem("access_token"),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import axiosInstance from "src/api/AxiosConfig";
|
||||
|
||||
const baseURL = "";
|
||||
const baseURL = import.meta.env.VITE_BASE_URL;
|
||||
|
||||
export const createTask = (endpoint, data) => {
|
||||
return axiosInstance
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import axios from "axios";
|
||||
|
||||
const ApiUpdateUserProfile = async formData => {
|
||||
const baseURL = import.meta.env.VITE_BASE_URL;
|
||||
|
||||
const ApiUpdateUserProfile = async (formData) => {
|
||||
try {
|
||||
const response = await axios.post("http://127.0.1:8000/api/user/update/", formData, {
|
||||
const response = await axios.post(`${baseURL}user/update/`, formData, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + localStorage.getItem("access_token"),
|
||||
"Content-Type": "multipart/form-data",
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import axios from "axios";
|
||||
|
||||
const baseURL = import.meta.env.VITE_BASE_URL;
|
||||
|
||||
async function refreshAccessToken() {
|
||||
const refresh_token = localStorage.getItem("refresh_token");
|
||||
const access_token = localStorage.getItem("access_token");
|
||||
@ -12,7 +14,7 @@ async function refreshAccessToken() {
|
||||
return false;
|
||||
}
|
||||
|
||||
const refreshUrl = "http://127.0.0.1:8000/api/token/refresh/";
|
||||
const refreshUrl = `${baseURL}token/refresh/`;
|
||||
|
||||
try {
|
||||
const response = await axios.post(refreshUrl, { refresh: refresh_token });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user