Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

bug: `projects create-platform` fails with "Access to this API is forbidden" in CLI v16

Đã đóng Phù hợp với người mới
#282 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
node.js, typescript
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu trong dist/cli.cjs tại getProjectsClient và so sánh với phần triển khai trước đó trong lib/commands/projects.js. Tái hiện appwrite projects create-platform bằng CLI v16, xác minh rằng tất cả các lệnh con của projects đều sử dụng client Console và xác nhận rằng lỗi truy cập bị cấm không còn xảy ra.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Description

Running appwrite projects create-platform fails with:

Error: Access to this API is forbidden.

And if no appwrite.config.json exists in the current directory, it fails earlier with:

Error: Project is not set. Please run appwrite init project to initialize...

Steps to Reproduce

  1. Install [email protected]
  2. Run appwrite login
  3. Run:
    appwrite projects create-platform \
      --project-id <your-project-id> \
      --type web \
      --name "My App" \
      --hostname localhost
    
  4. Observe: Error: Access to this API is forbidden.

Root Cause

In dist/cli.cjs, getProjectsClient uses sdkForProject() instead of sdkForConsole():

// ❌ Current (broken) — sets x-appwrite-project to local project ID
const getProjectsClient = async () => {
  const sdkClient = await sdkForProject();
  ...
};

The server-side projects.php enforces that x-appwrite-project must be console:

if ($project->getId() !== 'console') {
    throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN);
}

The fix is to use sdkForConsole(), which correctly sets x-appwrite-project: console. This matches the behavior of the old lib/commands/projects.js before the TypeScript migration.

// ✅ Fix
const getProjectsClient = async () => {
  const sdkClient = await sdkForConsole();
  ...
};

This affects all appwrite projects subcommands (create-platform, list-platforms, create-key, list-keys, etc.).

Environment

  • CLI version: 16.0.0
  • Appwrite server: 1.8.1 (self-hosted)
  • Node: v22.x
Ngôn ngữ chính
Go
Star
103
Fork
45
Merge trung bình
4 giờ 2 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.