Browse Source

代理

pull/11591/head
子阳 4 months ago
parent
commit
191eb7cd8e
  1. 6
      config/proxy.ts
  2. 21
      mock/user.ts

6
config/proxy.ts

@ -12,10 +12,10 @@
export default { export default {
// 如果需要自定义本地开发服务器 请取消注释按需调整 // 如果需要自定义本地开发服务器 请取消注释按需调整
dev: { dev: {
// localhost:8000/api/** -> https://preview.pro.ant.design/api/** // localhost:8003/api/** -> http://localhost:8003/api/
'/api/': { '/api/': {
// 要代理的地址 - 使用本地mock服务 // 要代理的地址 - 指向开发服务器自身
target: 'http://localhost:8000', target: 'http://localhost:8003',
// 配置了这个可以从 http 代理到 https // 配置了这个可以从 http 代理到 https
// 依赖 origin 的功能可能需要这个,比如 cookie // 依赖 origin 的功能可能需要这个,比如 cookie
changeOrigin: true, changeOrigin: true,

21
mock/user.ts

@ -157,6 +157,27 @@ export default {
}); });
access = 'guest'; access = 'guest';
}, },
// 支持GET请求的登录接口
'GET /api/login/account': async (req: Request, res: Response) => {
const { token, username, type } = req.query;
await waitTime(1000);
if (token === '123' || username === 'admin') {
res.send({
status: 'ok',
type: type || 'account',
currentAuthority: 'admin',
token: '123',
});
access = 'admin';
return;
}
res.send({
status: 'error',
type: type || 'account',
currentAuthority: 'guest',
});
access = 'guest';
},
'POST /api/login/outLogin': (_req: Request, res: Response) => { 'POST /api/login/outLogin': (_req: Request, res: Response) => {
access = ''; access = '';
res.send({ data: {}, success: true }); res.send({ data: {}, success: true });

Loading…
Cancel
Save