-
Notifications
You must be signed in to change notification settings - Fork 380
Description
When using API Gateway V2 with a custom domain (without Route53), Zappa causes a double stage redirect. The custom domain is already mapped to the correct stage in API Gateway's API Mappings, but Zappa still tries to redirect to the stage name, resulting in a duplicated stage path.
For example:
- Custom domain:
api.example.com - Stage:
dev - API Mapping:
api.example.com→devstage (path: empty)
When accessing https://api-test.maquinaweb.com.br/admin/, it redirects to https://api-test.maquinaweb.com.br/dev/admin/, which returns a "not found" error because the stage is duplicated in the path.
This resulting to https://api-test.maquinaweb.com.br/dev/dev/admin/
Steps to Reproduce
- Deploy the application with API Gateway V2:
zappa deploy dev - Create a custom domain in API Gateway (without using Route53/Certificate Manager integration from Zappa)
- Configure API Mapping with empty path pointing to your API and stage
- Access any endpoint through the custom domain
- Observe the redirect includes the stage name, causing a double stage path
This my configuration AWS Custom Domain Names with API mappings

Configuration
zappa_settings.json:
{
"dev": {
"aws_region": "sa-east-1",
"django_settings": "core.settings",
"exclude": [
"boto3",
"botocore",
"s3transfer",
"concurrent",
".env",
".venv",
".ruff_cache",
".vscode",
"media"
],
"profile_name": "myprofile",
"project_name": "myproject",
"architecture": "arm64",
"runtime": "python3.11",
"s3_bucket": "myproject-dev",
"environment_variables": {
"PRODUCTION": "True"
},
"memory_size": 1024,
"apigateway_version": "v2",
"base_path": ""
}
}Repository to replication: https://github.com/maquinaweb/test-zappa
Environment
- Zappa version: 0.61.3
- Python version: 3.11
- AWS Region: sa-east-1
- Architecture: arm64
- API Gateway version: v2
- Custom domain configured manually (not through Zappa)
What I've Tried
- Setting
"base_path": "/"in zappa_settings.json - But changed not redirects but all routes is 404 - Ensuring API Mapping path is empty - Still redirects with stage name
- Disabling the default API Gateway endpoint - Still redirects
Additional Context
This issue started occurring after migrating from API Gateway V1 (REST API) to API Gateway V2 (HTTP API). With V1, the custom domain worked correctly without the double stage redirect issue.
Is there a way to disable the automatic stage redirect behavior when using a custom domain with API Gateway V2?