提交 5c9afaf7 编写于 作者: C caoenze

bugfix: 修复因API MOCK请求拦截未考虑请求方法导致的跨域错误

上级 9a746eb6
......@@ -3,7 +3,7 @@ import {getGlobalData, RouterPlugin} from '@dokit/web-core'
import { getPartUrlByParam } from "@dokit/web-utils";
import { request } from './../../assets/util'
const mockBaseUrl = "https://pre.dokit.cn";
const mockBaseUrl = "https://www.dokit.cn";
const getCheckedInterfaceList = function (interfaceList) {
return interfaceList.filter(i => i.checked)
......@@ -80,6 +80,7 @@ export default new RouterPlugin({
})
}
})
sceneId && fetchArgs[1] && (fetchArgs[1].method = 'get')
sceneId && (fetchArgs[0] = `${mockBaseUrl}/api/app/scene/${sceneId}`)
return fetchArgs;
}
......@@ -99,6 +100,7 @@ export default new RouterPlugin({
})
}
})
sceneId && (args[0] = 'get')
sceneId && (args[1] = `${mockBaseUrl}/api/app/scene/${sceneId}`)
return args;
},
......
......@@ -13,8 +13,6 @@
<script>
import interfaceItem from "./interface-item";
const mockBaseUrl = "https://pre.dokit.cn";
export default {
components: {
interfaceItem,
......
......@@ -12,36 +12,36 @@
<h1>DoKit For Web</h1>
<h2>Playground</h2>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.1.5/vue.global.js"></script>
<script src="../packages/web/dist/dokit.js"></script>
<script>
Dokit.setProductId('379cca45571436f86c31d687578541fc')
</script>
<script>
setTimeout(() => {
// fetch('https://www.tianqiapi.com/free/day?appid=68852321&appsecret=BgGLDVc7', {
// body: JSON.stringify({
// a:1
// }),
// method: 'get',
// })
// .then((response) => {
// let weatherInfo = response.json();
// return weatherInfo;
// })
// .then((info) => {
// console.log('weatherInfo', info)
// });
fetch('https://www.tianqiapi.com/free/week?appid=68852321&appsecret=BgGLDVc7', {
// body: JSON.stringify({
// a:1
// }),
method: 'post',
})
.then((response) => {
let weatherInfo = response.json();
return weatherInfo;
})
.then((info) => {
console.log('weatherInfo', info)
});
function reqListener () {
console.log('asasdasd', this.responseText);
}
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("post", "https://www.tianqiapi.com/free/week?appid=68852321&appsecret=BgGLDVc7");
oReq.send(JSON.stringify({
a:1
}));
// function reqListener () {
// console.log('asasdasd', this.responseText);
// }
// var oReq = new XMLHttpRequest();
// oReq.addEventListener("load", reqListener);
// oReq.open("post", "https://www.tianqiapi.com/free/week?appid=68852321&appsecret=BgGLDVc7");
// oReq.send(JSON.stringify({
// a:1
// }));
}, 5000);
</script>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册