Files
tms-erp-web/.workbuddy/memory/2026-08-05.md
赵忠林 3268f12501 style(pagination): 优化分页组件上一页/下一页样式及环境配置说明
- 取消分页组件中上一页、下一页按钮的额外宽度设置,使其与页码按钮等宽
- 恢复上一页、下一页的原生箭头图标显示,取消自定义文字和隐藏图标的样式规则
- 更新分页相关的注释,明确首页/尾页按钮依旧由脚本控制不注入,上一页/下一页显示原生箭头
- 修改 .env.development 配置,增加 API 代理和跨域说明,避免直接使用绝对地址引发的 CORS 问题
- 优化 VITE_APP_API 配置为 /api,配合 Vite 代理减少跨域错误,保障开发环境稳定运行
2026-08-05 14:35:30 +08:00

13 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 2026-08-05 工作记录
## 排查:改线上接口后前端"运行不了"CORS 根因)
- 现象:用户将 `.env.development``VITE_APP_API` 改为 `http://172.16.203.228:8000/api`(直连线上/测试后端)后仍运行不了。
- 根因Saber3 的 axios 配了 `withCredentials = true``src/axios.js:79`。该后端openresty + blade-gateway对跨域请求返回 `Access-Control-Allow-Origin: *``Access-Control-Allow-Credentials: true`,浏览器规定 credentials 模式下 Allow-Origin 不能是 `*`,非法组合会被直接拒绝 → 所有接口失败。
- 之前用 `/api` 能跑是因为走 Vite 代理,浏览器请求同源 localhost:2888不触发跨域。
- 已改动:
1. `.env.development``VITE_APP_API` 改回 `/api`,并加注释说明两种模式。
2. `vite.config.mjs``server.proxy['/api']` target 改为 `http://172.16.203.228:8000`,并去掉 `rewrite` 去掉 `/api` 的逻辑(保留 `/api` 前缀,对齐 openresty 期望路径)。
- 注意:改 `.env` / `vite.config.mjs` 后必须重启 `npm run dev`Vite 启动时加载环境变量,运行中改动不会热更新)。
- 若确需直连绝对地址(如生产/部署):必须让后端 CORS 把 Allow-Origin 改为具体前端域名blade-gateway 的 CorsConfig 用 `setAllowedOriginPatterns` 或显式域名),不可用 `*` 配合 credentials。