配置自定义域名开发环境

- 修改hosts文件配置,添加测试域名映射
- 前端API地址改为 api.yourdomain.com:8080
- 后端服务绑定到 api.yourdomain.com:8080
- 前端开发服务器使用 test.yourdomain.com:5173
- 添加自动配置脚本和启动脚本
- 提供完整的域名配置指南和故障排除说明
- 支持更真实的开发环境模拟
This commit is contained in:
AIGC Developer
2025-10-23 10:40:57 +08:00
parent 68574fe33f
commit 26d10a3322
9 changed files with 483 additions and 5 deletions

View File

@@ -10,15 +10,15 @@ export default defineConfig({
}
},
server: {
port: 3000,
host: '0.0.0.0',
port: 5173,
host: 'test.yourdomain.com',
proxy: {
'/api': {
target: 'http://localhost:8080',
target: 'http://api.yourdomain.com:8080',
changeOrigin: true,
secure: false,
// 确保后端返回的 Set-Cookie 可被前端域接收与发送
cookieDomainRewrite: 'localhost',
cookieDomainRewrite: 'test.yourdomain.com',
cookiePathRewrite: '/',
configure: (proxy, _options) => {
proxy.on('error', (err, _req, _res) => {