Skip to content

chore: add Cloudflare Pages API proxy and fix build dependency resolution#27

Merged
web-ppanel merged 1 commit intoperfect-panel:mainfrom
Ember-Moth:dev
Mar 12, 2026
Merged

chore: add Cloudflare Pages API proxy and fix build dependency resolution#27
web-ppanel merged 1 commit intoperfect-panel:mainfrom
Ember-Moth:dev

Conversation

@Ember-Moth
Copy link
Copy Markdown
Contributor

@Ember-Moth Ember-Moth commented Mar 12, 2026

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • 💄 style
  • 🔨 chore
  • 📝 docs

🔀 变更说明 | Description of Change

fix: Cloudflare Pages 构建与 API 代理支持 / Cloudflare Pages build compatibility & API proxy

本次变更解决了在 Cloudflare Pages 环境下部署时遇到的依赖解析和跨域请求问题,具体包含以下三项改动:

  1. 新增 bunfig.toml
    将 Bun 的包安装模式设置为 hoisted(扁平化 node_modules),确保 Vite/Rollup 在 Cloudflare Pages CI 环境中能正确解析依赖。

  2. 显式声明 React 依赖
    apps/adminapps/userpackage.json 中分别添加 react@^19.2.0react-dom@^19.2.0,避免 hoisted 模式下因隐式依赖提升失败导致构建报错。

  3. 新增 Cloudflare Pages API 代理 functions/v1/[[path]].ts
    实现了一个 Cloudflare Pages Function,将 /v1/** 路径的请求透明转发至后端(由环境变量 API_BASE_URL 指定),并处理 CORS 及 Cloudflare 专属请求头的清理,使前端无需额外跨域配置即可访问 API。

📝 补充信息 | Additional Information

Cloudflare Pages 部署配置 / Deployment Configuration

Admin User
构建命令 Build command bun install && bunx turbo build --filter=ppanel-admin-web bun install && bunx turbo build --filter=ppanel-user-web
输出目录 Build output directory apps/admin/dist apps/user/dist

环境变量 Environment Variables

变量名 说明 默认值
API_BASE_URL 后端 API 地址 https://api.ppanel.dev
  • OPTIONS 预检请求统一返回 204,确保浏览器 CORS 预检正常通过。
  • 代理层已移除 set-cookie 响应头转发,避免 Cookie 属性不兼容问题。

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 12, 2026

Deploy Preview for ppane-docs ready!

Name Link
🔨 Latest commit 72633a9
🔍 Latest deploy log https://app.netlify.com/projects/ppane-docs/deploys/69b24c12159ddd00098b8f41
😎 Deploy Preview https://deploy-preview-27--ppane-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@web-ppanel web-ppanel merged commit 5224826 into perfect-panel:main Mar 12, 2026
8 checks passed
@web-ppanel
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.3.15 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants