mirror of
https://gitee.com/newgateway/vtj.git
synced 2026-05-07 01:10:03 +08:00
fix: 🐛 API代理
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
export default {
|
||||
'/api': {
|
||||
target: 'http://localhost:3000',
|
||||
target: 'http://localhost:8000',
|
||||
changeOrigin: true,
|
||||
ws: true
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import router from './router';
|
||||
import { AdapterPlugin, IconsPlugin } from '@vtj/web';
|
||||
// import ElementPlus from 'element-plus';
|
||||
import '@/style/index.scss';
|
||||
import './mock';
|
||||
// import './mock';
|
||||
|
||||
const app = createApp(App);
|
||||
app.use(router);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<ElButton @click="execApi1">Test api1</ElButton>
|
||||
<ElButton @click="doRequest">Test api2</ElButton>
|
||||
<ElButton @click="doRequest3">Test api3</ElButton>
|
||||
<ElButton @click="doRequest4">Test api4</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
@@ -79,6 +80,12 @@
|
||||
});
|
||||
};
|
||||
|
||||
const doRequest4 = () => {
|
||||
request({
|
||||
url: 'https://app.vtj.pro/api/proxy'
|
||||
});
|
||||
};
|
||||
|
||||
// const url = '/api/test/user/${id}';
|
||||
// const url = '/api/scm/auth/scm/scmPurchaseApplyH/waitList.do';
|
||||
// const url = '/mock/api/:id.json';
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": [
|
||||
"vite.config.ts",
|
||||
"proxy.config.ts"
|
||||
]
|
||||
}
|
||||
"include": ["vite.config.ts", "proxy.config.ts"]
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ function creator() {
|
||||
],
|
||||
plugins: [
|
||||
createDevTools({
|
||||
hm: null,
|
||||
hm: '',
|
||||
link: false,
|
||||
copy: false,
|
||||
devMode: true,
|
||||
|
||||
@@ -28,6 +28,7 @@ const DATA_METHODS = ['put', 'post', 'patch'];
|
||||
const LOCAL_REQUEST_ID = 'Local-Request-Id';
|
||||
const LOADING_DELAY = 100;
|
||||
const ERROR_DELAY = 300;
|
||||
const PROXY_PATH = '/api/proxy';
|
||||
|
||||
export interface IRequestSkipWarn {
|
||||
// 处理程序
|
||||
@@ -337,7 +338,7 @@ export class Request {
|
||||
headers
|
||||
};
|
||||
}
|
||||
const path = settings.proxyPath || '/api/open/proxy/v1';
|
||||
const path = settings.proxyPath || PROXY_PATH;
|
||||
const { protocol, host } = location || {};
|
||||
const target = isUrl(url) ? url : `${protocol}//${host}${url}`;
|
||||
headers.Target = target;
|
||||
|
||||
Reference in New Issue
Block a user