feat: use API base URL from env
This commit is contained in:
@@ -22,3 +22,8 @@ dist-ssr
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
|
#env files
|
||||||
|
.env
|
||||||
|
.env.*.local
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import type {InternalAxiosRequestConfig} from "axios";
|
import type {InternalAxiosRequestConfig} from "axios";
|
||||||
|
|
||||||
const BASE_URL: string = "http://localhost:3000/api";
|
const baseURL: string = import.meta.env.VITE_API_URL;
|
||||||
|
|
||||||
const apiClient = axios.create({
|
const apiClient = axios.create({
|
||||||
baseURL: BASE_URL,
|
baseURL: baseURL,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export function BytescaleUploader({
|
|||||||
onChange,
|
onChange,
|
||||||
folderPath,
|
folderPath,
|
||||||
}: BytescaleUploaderProps) {
|
}: BytescaleUploaderProps) {
|
||||||
|
const baseURL = import.meta.env.VITE_API_URL;
|
||||||
const [isUploading, setIsUploading] = useState(false);
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
@@ -33,15 +34,11 @@ export function BytescaleUploader({
|
|||||||
formData.append("folderPath", folderPath);
|
formData.append("folderPath", folderPath);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(`${baseURL}/upload`, formData, {
|
||||||
"http://localhost:3000/api/upload",
|
headers: {
|
||||||
formData,
|
"Content-Type": "multipart/form-data",
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "multipart/form-data",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
const {fileUrl} = response.data;
|
const {fileUrl} = response.data;
|
||||||
onChange(fileUrl);
|
onChange(fileUrl);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: "http://localhost:3000/api",
|
baseURL: import.meta.env.VITE_API_URL,
|
||||||
});
|
});
|
||||||
|
|
||||||
api.interceptors.request.use((config) => {
|
api.interceptors.request.use((config) => {
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
Reference in New Issue
Block a user