根据location.host判断api的host

This commit is contained in:
zhl 2023-04-19 15:15:56 +08:00
parent e6164734a9
commit 2facd8f67a

View File

@ -1,5 +1,6 @@
const { createApp } = Vue; const { createApp } = Vue;
const API_BASE = "https://xwork.kingsome.cn"; const API_BASE = "https://xwork.kingsome.cn";
const API_BASE_LOCAL = "http://localhost:3002";
const TASK_INFO_URL = "/workflow/task"; const TASK_INFO_URL = "/workflow/task";
const DEFAULT_CHAIN_DATA = { const DEFAULT_CHAIN_DATA = {
@ -53,7 +54,8 @@ async function connectMetaMask() {
} }
const fetchTaskInfo = function (taskId) { const fetchTaskInfo = function (taskId) {
const url = `${API_BASE}${TASK_INFO_URL}/${taskId}`; const host = location.host === "localhost" ? API_BASE_LOCAL : API_BASE;
const url = `${host}${TASK_INFO_URL}/${taskId}`;
return fetch(url) return fetch(url)
.then((response) => { .then((response) => {
if (!response.ok) { if (!response.ok) {