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
- Install
appwrite-cli@16.0.0
- Run
appwrite login
- Run:
appwrite projects create-platform \
--project-id <your-project-id> \
--type web \
--name "My App" \
--hostname localhost
- 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
Bug Description
Running
appwrite projects create-platformfails with:And if no
appwrite.config.jsonexists in the current directory, it fails earlier with:Steps to Reproduce
appwrite-cli@16.0.0appwrite loginError: Access to this API is forbidden.Root Cause
In
dist/cli.cjs,getProjectsClientusessdkForProject()instead ofsdkForConsole():The server-side
projects.phpenforces thatx-appwrite-projectmust beconsole:The fix is to use
sdkForConsole(), which correctly setsx-appwrite-project: console. This matches the behavior of the oldlib/commands/projects.jsbefore the TypeScript migration.This affects all
appwrite projectssubcommands (create-platform,list-platforms,create-key,list-keys, etc.).Environment