docker化项目
> 还删除无关的public/vite.svg文件
Change-Id: If26b139f8a984aec1518c0233b52d2a6a25a5bb7
diff --git a/src/api/interceptors.ts b/src/api/interceptors.ts
new file mode 100644
index 0000000..3b31740
--- /dev/null
+++ b/src/api/interceptors.ts
@@ -0,0 +1,20 @@
+import axios from "axios";
+import { useNavigate } from "react-router";
+
+// 为所有auth外请求添加token头
+axios.interceptors.request.use((config) => {
+ const requestUrl = config.url;
+ if (requestUrl?.includes("/auth/")) {
+ config.url = requestUrl.replace("/auth/","/");
+ } else {
+ const token = localStorage.getItem('token');
+ if (!token) {
+ const navigate = useNavigate();
+ navigate("/login")
+ }
+ config.headers['Authorization'] = `Bearer ${token}`;
+ }
+ return config;
+}, (error) => {
+ return error;
+} );
\ No newline at end of file