From 5da38ccded786b81cc7e997616bd879c97cf30a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=86=E4=BC=AF=E8=A8=80?= <104855611+maoxuner@users.noreply.github.com> Date: Wed, 1 Jul 2026 13:02:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4mock=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=20(#8108)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 调整mock默认路由 1. starting改为running 语义更明确 2. API地址修复 3. 列表顺序调整,登录接口靠前 * docs: 替换axios调用示例 原先/api/user接口地址不对,且是受认证保护的接口,响应异常容易造成误解 --- apps/backend-mock/routes/[...].ts | 10 +++++----- docs/src/en/guide/essentials/server.md | 12 +++++++----- docs/src/guide/essentials/server.md | 12 +++++++----- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/apps/backend-mock/routes/[...].ts b/apps/backend-mock/routes/[...].ts index 5a22563dc..44038cf7c 100644 --- a/apps/backend-mock/routes/[...].ts +++ b/apps/backend-mock/routes/[...].ts @@ -3,13 +3,13 @@ import { defineEventHandler } from 'h3'; export default defineEventHandler(() => { return `

Hello Vben Admin

-

Mock service is starting

+

Mock service is running

`; }); diff --git a/docs/src/en/guide/essentials/server.md b/docs/src/en/guide/essentials/server.md index b17db80dd..3a863a33e 100644 --- a/docs/src/en/guide/essentials/server.md +++ b/docs/src/en/guide/essentials/server.md @@ -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. ::: diff --git a/docs/src/guide/essentials/server.md b/docs/src/guide/essentials/server.md index 2ae16e763..b2ed79ba5 100644 --- a/docs/src/guide/essentials/server.md +++ b/docs/src/guide/essentials/server.md @@ -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。 :::