diff --git a/amplify.yml b/amplify.yml index 45e88eac..34174f9e 100644 --- a/amplify.yml +++ b/amplify.yml @@ -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 diff --git a/middleware.ts b/middleware.ts index 5a647796..9395201b 100644 --- a/middleware.ts +++ b/middleware.ts @@ -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) diff --git a/package.json b/package.json index 5afdbe72..665c6dc7 100644 --- a/package.json +++ b/package.json @@ -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"