26 lines
1.3 KiB
Markdown
26 lines
1.3 KiB
Markdown
# Cloudflare Account Troubleshooting
|
|
|
|
Reference for Cloudflare account and API token troubleshooting.
|
|
|
|
Use `https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects` to verify the account ID and API token are valid.
|
|
|
|
## Validate Cloudflare account and API token
|
|
|
|
```powershell
|
|
# Validate Cloudflare account and API token in .env
|
|
Set-Location -Path "E:\Documents\02-Projects\07-Mentoring\Corey\linearvoid"
|
|
Get-Content .env | Select-String 'CLOUDFLARE_API_TOKEN'
|
|
Get-Content .env | Select-String 'CLOUDFLARE_ACCOUNT_ID'
|
|
|
|
# Test API token with curl
|
|
$env:CLOUDFLARE_API_TOKEN = (Get-Content .env | Select-String 'CLOUDFLARE_API_TOKEN' | ForEach-Object { $_.Line.Split('=')[1].Trim() })
|
|
$env:CLOUDFLARE_ACCOUNT_ID = (Get-Content .env | Select-String 'CLOUDFLARE_ACCOUNT_ID' | ForEach-Object { $_.Line.Split('=')[1].Trim() })
|
|
|
|
# List all Pages projects for the account
|
|
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$env:CLOUDFLARE_ACCOUNT_ID/pages/projects" -H "Authorization: Bearer $env:CLOUDFLARE_API_TOKEN" -H "Content-Type: application/json"
|
|
|
|
# Create a new Pages project (if needed)
|
|
curl -X POST "https://api.cloudflare.com/client/v4/accounts/$env:CLOUDFLARE_ACCOUNT_ID/pages/projects" -H "Authorization: Bearer $env:CLOUDFLARE_API_TOKEN" -H "Content-Type: application/json" -d '{"name":"linearvoid","production_branch":"main"}'
|
|
|
|
```
|