diff --git a/app/[store]/page.tsx b/app/[store]/page.tsx
new file mode 100644
index 00000000..c915d28f
--- /dev/null
+++ b/app/[store]/page.tsx
@@ -0,0 +1,14 @@
+'use client'
+
+import { useParams } from 'next/navigation'
+
+export default function StorePage() {
+ const params = useParams()
+ const store = params.store
+
+ return (
+
+
Tienda: {store}
+
+ )
+}
diff --git a/middleware.ts b/middleware.ts
index aa816b53..244ced07 100644
--- a/middleware.ts
+++ b/middleware.ts
@@ -8,6 +8,42 @@ import { handleCollectionOwnershipMiddleware } from './middlewares/ownership/col
export async function middleware(request: NextRequest) {
const path = request.nextUrl.pathname
+ const hostname = request.headers.get('host') || ''
+
+ // Configuración de dominios
+ const isProduction = process.env.NODE_ENV === 'production'
+
+ // Detectar subdominios
+ let subdomain = ''
+ if (isProduction) {
+ // En producción: verificar si hay un subdominio (ej: tienda.fasttify.com)
+ const allowedDomains = ['fasttify.com', 'www.fasttify.com'];
+ const parts = hostname.split('.');
+ const domain = parts.slice(-2).join('.');
+ if (parts.length > 2 && allowedDomains.includes(domain)) {
+ subdomain = parts[0];
+ }
+ } else {
+ // En desarrollo: usar el formato subdominio.localhost:3000 o localhost:3000
+ if (hostname.includes('.localhost')) {
+ subdomain = hostname.split('.')[0]
+ }
+ }
+
+ // Si hay un subdominio y estamos en la raíz, reescribir a la ruta de la tienda
+ if (subdomain && subdomain !== 'www' && path === '/') {
+ // Reescribir la URL para mostrar la página de la tienda
+ const url = request.nextUrl.clone()
+ url.pathname = `/${subdomain}`
+ return NextResponse.rewrite(url)
+ }
+
+ // Si hay un subdominio y la ruta no empieza con el subdominio, agregar el prefijo
+ if (subdomain && subdomain !== 'www' && !path.startsWith(`/${subdomain}`)) {
+ const url = request.nextUrl.clone()
+ url.pathname = `/${subdomain}${path}`
+ return NextResponse.rewrite(url)
+ }
// Verificar propiedad de productos específicos
if (
@@ -45,12 +81,5 @@ export async function middleware(request: NextRequest) {
}
export const config = {
- matcher: [
- '/subscription-success',
- '/account-settings',
- '/first-steps',
- '/my-store',
- '/login',
- '/store/:path*',
- ],
+ matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
}