fix: 调整mock默认路由 (#8108)
* fix: 调整mock默认路由 1. starting改为running 语义更明确 2. API地址修复 3. 列表顺序调整,登录接口靠前 * docs: 替换axios调用示例 原先/api/user接口地址不对,且是受认证保护的接口,响应异常容易造成误解
This commit is contained in:
@@ -63,16 +63,18 @@ Based on the above configuration, we can use `/api` as the prefix for API reques
|
||||
```ts
|
||||
import axios from 'axios';
|
||||
|
||||
axios.get('/api/user').then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
axios
|
||||
.post('/api/auth/login', { username: 'vben', password: '123456' })
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
```
|
||||
|
||||
At this point, the request will be proxied to `http://localhost:5320/api/user`.
|
||||
At this point, the request will be proxied to `http://localhost:5320/api/auth/login`.
|
||||
|
||||
::: warning Note
|
||||
|
||||
From the browser's console Network tab, the request appears as `http://localhost:5555/api/user`. This is because the proxy configuration does not change the local request's URL.
|
||||
From the browser's console Network tab, the request appears as `http://localhost:5555/api/auth/login`. This is because the proxy configuration does not change the local request's URL.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
@@ -63,16 +63,18 @@ export default defineConfig(async () => {
|
||||
```ts
|
||||
import axios from 'axios';
|
||||
|
||||
axios.get('/api/user').then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
axios
|
||||
.post('/api/auth/login', { username: 'vben', password: '123456' })
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
```
|
||||
|
||||
此时,请求会被代理到 `http://localhost:5320/api/user`。
|
||||
此时,请求会被代理到 `http://localhost:5320/api/auth/login`。
|
||||
|
||||
::: warning 注意
|
||||
|
||||
从浏览器控制台的 Network 看,请求是 `http://localhost:5555/api/user`, 这是因为 proxy 配置不会改变本地请求的 url。
|
||||
从浏览器控制台的 Network 看,请求是 `http://localhost:5555/api/auth/login`, 这是因为 proxy 配置不会改变本地请求的 url。
|
||||
|
||||
:::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user