From 2fd5a6c2f6087ab8f5aebeb5505567aa0fce0945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96MER=20FARUK=20CO=C5=9EKUN?= Date: Tue, 19 May 2026 17:20:07 +0300 Subject: [PATCH] fix(api): run wrangler from repo root via --config flag wrangler 4.x auto-detects the project type from cwd and errors when run from the monorepo root without a target. Fix: - wrangler.toml: main path changed from ../../dist/apps/api/worker.js to dist/apps/api/worker.js (relative to repo root) - deploy / deploy:preview / cf:dev targets: removed cwd override, pass --config apps/api/wrangler.toml so wrangler is always invoked from the workspace root where the dist/ output lives - README: update Cloudflare CI/CD deploy command examples to match Co-Authored-By: Claude Sonnet 4.6 --- README.md | 4 ++-- apps/api/project.json | 11 ++++------- apps/api/wrangler.toml | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a6d5a7d..e53cf15 100644 --- a/README.md +++ b/README.md @@ -152,8 +152,8 @@ When using Cloudflare's built-in CI/CD pipeline (**Workers & Pages → Create |---|---| | Project name | `minimalblock` | | Build command | `nx build:worker api` | -| Deploy command | `npx wrangler deploy` | -| Non-production branch deploy command | `npx wrangler versions upload` | +| Deploy command | `npx wrangler deploy --config apps/api/wrangler.toml` | +| Non-production branch deploy command | `npx wrangler versions upload --config apps/api/wrangler.toml` | | Root directory | `/` | Add all secrets from the table above as **Environment Variables** in the Cloudflare dashboard before the first deploy. diff --git a/apps/api/project.json b/apps/api/project.json index 6ec4762..1689c3d 100644 --- a/apps/api/project.json +++ b/apps/api/project.json @@ -73,12 +73,11 @@ "dependsOn": ["build:worker"], "executor": "nx:run-commands", "options": { - "cwd": "apps/api", - "command": "npx wrangler deploy" + "command": "npx wrangler deploy --config apps/api/wrangler.toml" }, "configurations": { "preview": { - "command": "npx wrangler versions upload" + "command": "npx wrangler versions upload --config apps/api/wrangler.toml" } } }, @@ -86,16 +85,14 @@ "dependsOn": ["build:worker"], "executor": "nx:run-commands", "options": { - "cwd": "apps/api", - "command": "npx wrangler versions upload" + "command": "npx wrangler versions upload --config apps/api/wrangler.toml" } }, "cf:dev": { "continuous": true, "executor": "nx:run-commands", "options": { - "cwd": "apps/api", - "command": "npx wrangler dev ../../dist/apps/api/worker.js --port 8787" + "command": "npx wrangler dev dist/apps/api/worker.js --config apps/api/wrangler.toml --port 8787" } }, "prune-lockfile": { diff --git a/apps/api/wrangler.toml b/apps/api/wrangler.toml index 5d0f5a0..7f8e609 100644 --- a/apps/api/wrangler.toml +++ b/apps/api/wrangler.toml @@ -1,5 +1,5 @@ name = "minimalblock" -main = "../../dist/apps/api/worker.js" +main = "dist/apps/api/worker.js" compatibility_date = "2024-09-23" compatibility_flags = ["nodejs_compat"]