Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ frontend:
preBuild:
commands:
- nvm use 22
- npm ci
- npm ci --include=dev
- echo "Skipping husky setup in production"
build:
commands:
- npm run build
Expand Down
15 changes: 8 additions & 7 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ export async function middleware(request: NextRequest) {
const isProduction = process.env.NODE_ENV === 'production'

const allowedDomains = isProduction ? ['fasttify.com'] : ['localhost']
const isValidHostname = allowedDomains.some(
domain => hostname === domain || hostname.endsWith(`.${domain}`)
)

// Si el hostname es válido, redirigir a la landing
const isMainDomain = allowedDomains.some(domain => {
const cleanHostname = hostname.split(':')[0]
return cleanHostname === domain || cleanHostname === `www.${domain}`
})

if (isValidHostname) {
return NextResponse.redirect(new URL('/', request.url))
// Si estamos accediendo al dominio principal, continuar con la ruta normal
if (isMainDomain) {
return NextResponse.next()
}

// Detectar subdominios
const extractSubdomain = (hostname: string, isProduction: boolean): string => {
const cleanHostname = hostname.split(':')[0] // Remove port if present
const cleanHostname = hostname.split(':')[0]
const parts = cleanHostname.split('.')
if (isProduction) {
// En producción: verificar si hay un subdominio (ej: tienda.fasttify.com)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"prepare": "husky",
"prepare": "if command -v husky >/dev/null 2>&1; then husky; fi",
"postinstall": "if [ \"$NODE_ENV\" != \"production\" ] && command -v husky >/dev/null 2>&1; then husky; fi",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
Expand Down