Skip to content

Commit e9b294a

Browse files
authored
fix: resolver problema de URLs sin extensión .html en producción y staging (#45)
* fix(config): agregar use_directory_urls para manejar URLs sin extensión - Configurar use_directory_urls: true en mkdocs.yml - Permite que URLs como /meetups/ funcionen correctamente - Mantiene compatibilidad con estructura de directorios de MkDocs * feat(infra): implementar CloudFront Function para URLs sin extensión - Agregar CloudFront Function url_rewrite para manejar URLs sin .html - Función redirige /meetups/ a /meetups/index.html automáticamente - Asociar función con todos los cache behaviors para consistencia - Soluciona problema de enlaces que no funcionan en producción * docs: agregar documentación para fix de URLs sin extensión - Documentar problema de URLs que no funcionan en producción - Explicar solución implementada con CloudFront Function - Incluir pasos de despliegue y verificación - Agregar notas técnicas sobre funcionamiento de la solución * feat(infra): aplicar CloudFront Function a staging environment - Agregar función url_rewrite a todos los cache behaviors de staging - Reutilizar la misma CloudFront Function global para consistencia - Soluciona problema de URLs sin extensión en staging.pythoncdmx.org - Mantiene configuración de cache más agresiva para staging * docs: actualizar documentación con soporte para staging - Agregar información sobre configuración de staging - Incluir URLs de verificación para ambos ambientes - Documentar que la misma CloudFront Function se reutiliza
1 parent a111f61 commit e9b294a

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

docs/URL_FIX_DOCUMENTATION.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ La función se asoció con todos los cache behaviors de CloudFront para asegurar
4343
## Archivos Modificados
4444

4545
1. **mkdocs.yml**: Agregada configuración `use_directory_urls: true`
46-
2. **terraform/cloudfront.tf**:
46+
2. **terraform/cloudfront.tf**:
4747
- Agregada CloudFront Function `url_rewrite`
4848
- Asociada la función con todos los cache behaviors
49+
3. **terraform/cloudfront-staging.tf**:
50+
- Aplicada la misma CloudFront Function a staging
51+
- Asociada la función con todos los cache behaviors de staging
4952

5053
## Despliegue
5154

@@ -67,11 +70,19 @@ Para aplicar estos cambios:
6770
## Verificación
6871

6972
Después del despliegue, verificar que funcionen:
73+
74+
### Producción
7075
-`https://pythoncdmx.org/meetups/`
7176
-`https://pythoncdmx.org/meetups/index.html`
7277
-`https://pythoncdmx.org/about/`
7378
-`https://pythoncdmx.org/about/index.html`
7479

80+
### Staging
81+
-`https://staging.pythoncdmx.org/meetups/`
82+
-`https://staging.pythoncdmx.org/meetups/index.html`
83+
-`https://staging.pythoncdmx.org/about/`
84+
-`https://staging.pythoncdmx.org/about/index.html`
85+
7586
## Notas Técnicas
7687

7788
- La CloudFront Function se ejecuta en el edge, por lo que tiene latencia mínima

terraform/cloudfront-staging.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ resource "aws_cloudfront_origin_access_control" "website_staging" {
77
signing_protocol = "sigv4"
88
}
99

10+
# CloudFront Function for staging (reuse the same function as production)
11+
# Note: CloudFront Functions are global, so we can reference the same function
12+
1013
# CloudFront distribution for staging
1114
resource "aws_cloudfront_distribution" "website_staging" {
1215
enabled = true
@@ -42,6 +45,12 @@ resource "aws_cloudfront_distribution" "website_staging" {
4245
default_ttl = 300 # 5 minutes - shorter cache for staging
4346
max_ttl = 3600 # 1 hour - shorter cache for staging
4447
compress = true
48+
49+
# Associate CloudFront Function for URL rewriting (same as production)
50+
function_association {
51+
event_type = "viewer-request"
52+
function_arn = aws_cloudfront_function.url_rewrite.arn
53+
}
4554
}
4655

4756
# Cache behavior for static assets (CSS) - shorter cache for staging
@@ -63,6 +72,12 @@ resource "aws_cloudfront_distribution" "website_staging" {
6372
default_ttl = 1800 # 30 minutes
6473
max_ttl = 7200 # 2 hours
6574
compress = true
75+
76+
# Associate CloudFront Function for URL rewriting
77+
function_association {
78+
event_type = "viewer-request"
79+
function_arn = aws_cloudfront_function.url_rewrite.arn
80+
}
6681
}
6782

6883
# Cache behavior for static assets (JS) - shorter cache for staging
@@ -84,6 +99,12 @@ resource "aws_cloudfront_distribution" "website_staging" {
8499
default_ttl = 1800 # 30 minutes
85100
max_ttl = 7200 # 2 hours
86101
compress = true
102+
103+
# Associate CloudFront Function for URL rewriting
104+
function_association {
105+
event_type = "viewer-request"
106+
function_arn = aws_cloudfront_function.url_rewrite.arn
107+
}
87108
}
88109

89110
# Cache behavior for images - shorter cache for staging
@@ -105,6 +126,12 @@ resource "aws_cloudfront_distribution" "website_staging" {
105126
default_ttl = 3600 # 1 hour
106127
max_ttl = 86400 # 24 hours
107128
compress = true
129+
130+
# Associate CloudFront Function for URL rewriting
131+
function_association {
132+
event_type = "viewer-request"
133+
function_arn = aws_cloudfront_function.url_rewrite.arn
134+
}
108135
}
109136

110137
# Custom error responses for SPA-like behavior

0 commit comments

Comments
 (0)