Skip to content

Commit

Permalink
分离配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
BeiyanYunyi committed Jul 14, 2021
1 parent 6eea2b4 commit 20c4f21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/controller/request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";
import { io, Socket } from "socket.io-client";
import backendURL from "../data/backendURL";
import backendURL, { host, backendPath } from "../data/backendURL";

class RequestController {
private config = { headers: {} };
Expand All @@ -14,8 +14,8 @@ class RequestController {
headers: { Authorization: `Bearer ${tokenToSet}` },
};
this.token = tokenToSet;
const socket = io({
path: "/api/ws",
const socket = io(host, {
path: `/${backendPath}/ws`,
auth: { token: `Bearer ${tokenToSet}` },
autoConnect: false,
});
Expand Down
4 changes: 3 additions & 1 deletion src/data/backendURL.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export default "/api";
export const host = "/";
export const backendPath = "api";
export default `${host}${backendPath}`;

0 comments on commit 20c4f21

Please sign in to comment.