跳到主内容
@wquguru
精选86Vox工具与服务

Claude Code 部署避坑指南:15个常见错误与 Synteq 一键部署

Claude Code tip: works on localhost, breaks in production. These are the 15 plac…

原文
发到 X
推荐理由

结构非常完整,先通过具体的 15 个技术痛点建立专业信任,再自然引出 Synteq 作为解决方案,且提供了可直接复制使用的 Prompt 模板,对创作者和开发者都有很高的参考价值。

Claude Code tip: works on localhost, breaks in production. These are the 15 places a vibe-coded app's first deploy usually falls over. Before you deploy, have Opus 5.5 send out 4 subagents to check them, fix everything in one pass, then ship with one command:

Claude Code 提示:在本地主机上运行正常,在生产环境中却会出错。以下是 vibe-coded 应用首次部署时通常会在 15 个地方失败的地方。在部署之前,让 Opus 5.5 派出 4 个子代理进行检查,一次性修复所有问题,然后通过一条命令进行发布:

From your laptop to a server → Replace every hard-coded http://localhost:3000 with an environment variable or a relative path → If the server only listens on localhost, switch it to 0.0.0.0 and read the port from the PORT environment variable → If you only ever run npm run dev, run build and then start locally once. Dev lets TypeScript type errors slide; build fails on them → Check that import paths match the real file names, including case. On a Mac, ./Components/button still finds ./components/Button. On a Linux server it's "module not found" → Anything that only exists on your machine (globally installed tools, your local Node version) goes into package.json

从你的笔记本电脑到服务器 → 将每个硬编码的 http://localhost:3000 替换为环境变量或相对路径 → 如果服务器仅在 localhost 上监听,将其切换为 0.0.0.0 并从 PORT 环境变量中读取端口 → 如果你只运行 npm run dev,先运行 build,然后只在本地启动一次。Dev 模式会让 TypeScript 类型错误滑过;build 则会因这些错误而失败 → 检查导入路径是否与真实文件名匹配,包括大小写。在 Mac 上,./Components/button 仍然能找到 ./components/Button。在 Linux 服务器上则是“模块未找到” → 任何仅存在于你机器上的东西(全局安装的工具、你本地的 Node 版本)都应放入 package.json

Secrets and environment variables → List every environment variable the code reads and check it against .env. Flag what's missing and what's unused → Check every key that shows up in frontend code. Apart from the ones meant to be public (like Supabase's anon key, as long as every table has RLS on), move them all to the server → Variables starting with NEXT_PUBLIC_ or VITE_ get baked in at build time. Make them available to the build on your host, and rebuild after changing them → Check whether .env was ever committed to git. Rotate every key that's in the history

密钥和环境变量 → 列出代码读取的所有环境变量,并与 .env 进行核对。标记缺失和未使用的项 → 检查前端代码中出现的所有密钥。除了那些旨在公开的密钥(如 Supabase 的匿名密钥,只要每张表都启用了 RLS),将它们全部移至服务器端 → 以 NEXT_PUBLIC_ 或 VITE_ 开头的变量会在构建时被烘焙进去。在你的主机上使它们对构建可用,并在更改后重新构建 → 检查 .env 是否曾被提交到 git。轮换历史中存在的所有密钥

Data and new releases → User uploads and SQLite databases on local disk disappear on a restart or a new release. Move them to object storage and a managed database → Make database migrations their own command that runs before the new version takes traffic. Only add, never drop, so the old version still runs on the new schema → Login sessions and rate-limit counters kept in memory reset on every release, and each running copy keeps its own. Scheduled jobs run once per copy too

数据和新版本 → 用户上传的文件和本地磁盘上的 SQLite 数据库在重启或新发布时会消失。将它们移至对象存储和管理型数据库 → 使数据库迁移成为自己的命令,在新版本接管流量之前运行。只添加,不删除,以便旧版本仍能在新的架构上运行 → 保存在内存中的登录会话和速率限制计数器在每个发布时都会重置,并且每个运行的副本都有自己的。计划任务也会为每个副本运行一次

Switching to your live domain → Add your live domain to Supabase auth's Site URL and redirect URLs, and to your Google and GitHub login callbacks. Otherwise confirmation emails still open localhost → In Stripe, create a new webhook for your live URL and use its own signing secret. The one stripe listen gave you won't verify in production → Update CORS allowed origins, the cookie domain and the Secure flag for your live https domain

切换到你的实时域名 → 将你的实时域名添加到 Supabase auth 的 Site URL 和重定向 URL,以及 Google 和 GitHub 登录回调中。否则确认邮件仍然会打开 localhost → 在 Stripe 中,为你的实时 URL 创建一个新的 webhook 并使用其自己的签名密钥。stripe listen 给你的那个密钥在生产环境中无法验证 → 更新 CORS 允许的来源、cookie 域名和你的实时 https 域名的 Secure 标志

The moment you go live → Add a /healthz that needs no login and returns 200 within a few seconds. New versions only take traffic once they pass it → Once it's up, keep the live logs open and click through sign-up, login and payment on the live URL → Write down the rollback command so one command takes you back to the previous version. Database migrations don't roll back with it → Have it turn these 15 checks into a script in the repo, and run it before every deploy

上线的那一刻 → 添加一个无需登录且能在几秒内返回 200 状态的 /healthz 端点。新版本只有在通过该检查后才会接收流量 → 一旦服务启动,保持实时日志打开,并在实时 URL 上依次点击注册、登录和支付流程 → 记下回滚命令,以便一条命令即可让你回到上一个版本。数据库迁移不会随此命令一起回滚 → 将这 15 项检查转化为仓库中的脚本,并在每次部署前运行它

Once the code's fixed, deploy with Cloud Apps, which @synteq launched today for indie developers and small teams. Run these three lines in your project folder and you get an https .synteq.app link: npm install -g synteq synteq login synteq deploy

代码修复后,使用 Cloud Apps 进行部署,Synteq 今天为此面向独立开发者和小型团队推出了该服务。在项目文件夹中运行以下三行命令,即可获得一个 https .synteq.app 链接: npm install -g synteq synteq login synteq deploy

Connect GitHub and every push to the branch you pick goes live on its own, or skip the terminal and drag and drop your project in. A new version only takes traffic after it passes the health check; if it fails, the old one keeps serving.

连接 GitHub,推送到你指定分支的每一次提交都会自动上线;或者跳过终端,直接将项目拖拽上传。新版本只有在通过健康检查后才会接收流量;如果失败,旧版本将继续提供服务。

The default medium effort is enough. Get the data group wrong and you lose user data, so raise that one to high.

默认的中等工作量(medium effort)已足够。如果数据组配置错误,你会丢失用户数据,因此请将其提升至高(high)。

Send this whole post to Claude Code. If you need to, add this line at the end 👇 "Send one subagent to each of the first four groups. Check only, don't fix, and for each problem say which file it's in and how it breaks once live. Run the data subagent at high effort. Then fix everything yourself from their lists, and run build then start locally. Deploy with the Synteq CLI: I'll run login and create the app myself in a terminal (synteq login, synteq link), and you confirm with synteq status before going on. I'll put the production values in .env.production. Don't read or print it; import it at deploy time with --env-file. Before the first deploy, set the health check path and the pre-deploy command with synteq app settings set. Once it's up, curl the homepage and /healthz and check synteq app logs --search error. For sign-up, login and payment, list the steps and I'll click through myself. List any leaked keys and I'll rotate them in each dashboard. Ask me before rewriting git history, changing the database, switching storage, adding a custom domain, or running anything that needs --yes."

将整篇文章发送给 Claude Code。如果需要,在末尾添加这一行 👇 "向前四个组各发送一个子代理。仅检查,不修复,并针对每个问题说明其所在文件以及上线后会如何出错。以高工作量运行数据子代理。然后从他们的列表中自行修复所有问题,并在本地运行 build 然后 start。使用 Synteq CLI 进行部署:我将在终端中自行运行 login 并创建应用(synteq login, synteq link),你在继续之前用 synteq status 确认。我会将生产环境的值放入 .env.production。不要读取或打印它;在部署时通过 --env-file 导入它。在首次部署前,使用 synteq app settings set 设置健康检查路径和预部署命令。一旦服务启动,curl 首页和 /healthz 并检查 synteq app logs --search error。对于注册、登录和支付,列出步骤,我将自行点击完成。列出任何泄露的密钥,我将在各个仪表板中轮换它们。在重写 git 历史、更改数据库、切换存储、添加自定义域名或运行需要 --yes 参数的任何操作之前,请先询问我。"

Comment "LAUNCH" on the post below. Synteq is giving away $20,000 in credits. I just commented

在下面的帖子下评论“LAUNCH”。Synteq 正在赠送价值 20,000 美元的积分。我刚发表了评论

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件