From 7e4fb6d62a25529040a4fb0bdedfe23627555e53 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 16 May 2026 16:51:59 -0400 Subject: [PATCH] update the domains --- .env.docker.dev | 11 +++++----- .env.docker.production | 14 ++++++------- .env.docker.production.example | 14 ++++++------- apps/admin/next.config.js | 1 + apps/dashboard/next.config.js | 1 + apps/dashboard/src/lib/urls.ts | 13 ++++++------ apps/dashboard/src/middleware.ts | 3 ++- apps/marketplace/next.config.js | 1 + docker-compose.production.yml | 36 ++++++++++++++++++-------------- 9 files changed, 50 insertions(+), 44 deletions(-) diff --git a/.env.docker.dev b/.env.docker.dev index 36f1f26..a651df8 100644 --- a/.env.docker.dev +++ b/.env.docker.dev @@ -4,12 +4,13 @@ API_PORT=4000 API_URL=http://localhost:4000 API_INTERNAL_URL=http://api:4000/api/v1 NEXT_PUBLIC_API_URL=http://localhost:4000/api/v1 -NEXT_PUBLIC_MARKETING_URL=http://localhost:3000 -NEXT_PUBLIC_MARKETPLACE_URL=http://localhost:3000/explore -NEXT_PUBLIC_DASHBOARD_URL=http://localhost:3001 -NEXT_PUBLIC_ADMIN_URL=http://localhost:3002 +NEXT_PUBLIC_MARKETING_URL=http://localhost:3003 +NEXT_PUBLIC_MARKETPLACE_URL=http://localhost:3000/marketplace +NEXT_PUBLIC_DASHBOARD_URL=http://localhost:3001/dashboard +NEXT_PUBLIC_ADMIN_URL=http://localhost:3002/admin NEXT_PUBLIC_PUBLIC_SITE_DOMAIN=localhost:3003 -DASHBOARD_URL=http://localhost:3001 +DASHBOARD_URL=http://localhost:3001/dashboard +ADMIN_URL=http://localhost:3002/admin JWT_SECRET=dev-secret JWT_EXPIRY=8h RENTER_JWT_EXPIRY=7d diff --git a/.env.docker.production b/.env.docker.production index 4c73881..e288886 100644 --- a/.env.docker.production +++ b/.env.docker.production @@ -1,9 +1,6 @@ # ── Traefik domains — used in docker-compose labels ────────────────────────── ACME_EMAIL=rentaldrivego@gmail.com -MARKETPLACE_DOMAIN=rentaldrivego.ma API_DOMAIN=api.rentaldrivego.ma -DASHBOARD_DOMAIN=dashboard.rentaldrivego.ma -ADMIN_DOMAIN=admin.rentaldrivego.ma PUBLIC_SITE_DOMAIN=rentaldrivego.ma PGMANAGE_DOMAIN=pgmanage.rentaldrivego.ma @@ -21,15 +18,16 @@ NEXT_PUBLIC_API_URL=https://api.rentaldrivego.ma/api/v1 # ── Frontend public URLs ─────────────────────────────────────────────────────── NEXT_PUBLIC_MARKETING_URL=https://rentaldrivego.ma -NEXT_PUBLIC_MARKETPLACE_URL=https://rentaldrivego.ma/explore -NEXT_PUBLIC_DASHBOARD_URL=https://dashboard.rentaldrivego.ma -NEXT_PUBLIC_ADMIN_URL=https://admin.rentaldrivego.ma +NEXT_PUBLIC_MARKETPLACE_URL=https://rentaldrivego.ma/marketplace +NEXT_PUBLIC_DASHBOARD_URL=https://rentaldrivego.ma/dashboard +NEXT_PUBLIC_ADMIN_URL=https://rentaldrivego.ma/admin NEXT_PUBLIC_PUBLIC_SITE_DOMAIN=rentaldrivego.ma -DASHBOARD_URL=https://dashboard.rentaldrivego.ma +DASHBOARD_URL=https://rentaldrivego.ma/dashboard +ADMIN_URL=https://rentaldrivego.ma/admin # ── CORS ────────────────────────────────────────────────────────────────────── # Comma-separated list of allowed browser origins. REQUIRED in production. -CORS_ORIGINS=https://rentaldrivego.ma,https://dashboard.rentaldrivego.ma,https://admin.rentaldrivego.ma +CORS_ORIGINS=https://rentaldrivego.ma # ── Auth ────────────────────────────────────────────────────────────────────── JWT_SECRET=PMPS5k0D7rUeJOk0NkhI5bRtoGjkUqjK diff --git a/.env.docker.production.example b/.env.docker.production.example index f684cab..e288886 100644 --- a/.env.docker.production.example +++ b/.env.docker.production.example @@ -1,9 +1,6 @@ # ── Traefik domains — used in docker-compose labels ────────────────────────── ACME_EMAIL=rentaldrivego@gmail.com -MARKETPLACE_DOMAIN=app.rentaldrivego.ma API_DOMAIN=api.rentaldrivego.ma -DASHBOARD_DOMAIN=dashboard.rentaldrivego.ma -ADMIN_DOMAIN=admin.rentaldrivego.ma PUBLIC_SITE_DOMAIN=rentaldrivego.ma PGMANAGE_DOMAIN=pgmanage.rentaldrivego.ma @@ -21,15 +18,16 @@ NEXT_PUBLIC_API_URL=https://api.rentaldrivego.ma/api/v1 # ── Frontend public URLs ─────────────────────────────────────────────────────── NEXT_PUBLIC_MARKETING_URL=https://rentaldrivego.ma -NEXT_PUBLIC_MARKETPLACE_URL=https://app.rentaldrivego.ma/explore -NEXT_PUBLIC_DASHBOARD_URL=https://dashboard.rentaldrivego.ma -NEXT_PUBLIC_ADMIN_URL=https://admin.rentaldrivego.ma +NEXT_PUBLIC_MARKETPLACE_URL=https://rentaldrivego.ma/marketplace +NEXT_PUBLIC_DASHBOARD_URL=https://rentaldrivego.ma/dashboard +NEXT_PUBLIC_ADMIN_URL=https://rentaldrivego.ma/admin NEXT_PUBLIC_PUBLIC_SITE_DOMAIN=rentaldrivego.ma -DASHBOARD_URL=https://dashboard.rentaldrivego.ma +DASHBOARD_URL=https://rentaldrivego.ma/dashboard +ADMIN_URL=https://rentaldrivego.ma/admin # ── CORS ────────────────────────────────────────────────────────────────────── # Comma-separated list of allowed browser origins. REQUIRED in production. -CORS_ORIGINS=https://rentaldrivego.ma,https://app.rentaldrivego.ma,https://dashboard.rentaldrivego.ma,https://admin.rentaldrivego.ma +CORS_ORIGINS=https://rentaldrivego.ma # ── Auth ────────────────────────────────────────────────────────────────────── JWT_SECRET=PMPS5k0D7rUeJOk0NkhI5bRtoGjkUqjK diff --git a/apps/admin/next.config.js b/apps/admin/next.config.js index 46bba73..6a82a72 100644 --- a/apps/admin/next.config.js +++ b/apps/admin/next.config.js @@ -3,6 +3,7 @@ const apiOrigin = (process.env.API_INTERNAL_URL ?? process.env.API_URL ?? 'http: const apiUrl = new URL(apiOrigin) const nextConfig = { + basePath: '/admin', images: { remotePatterns: [ { diff --git a/apps/dashboard/next.config.js b/apps/dashboard/next.config.js index e049ccb..6ea4e37 100644 --- a/apps/dashboard/next.config.js +++ b/apps/dashboard/next.config.js @@ -24,6 +24,7 @@ const storagePatterns = [ .filter((p, i, arr) => arr.findIndex((q) => q.hostname === p.hostname && q.port === p.port) === i) const nextConfig = { + basePath: '/dashboard', images: { remotePatterns: [ { diff --git a/apps/dashboard/src/lib/urls.ts b/apps/dashboard/src/lib/urls.ts index 30e46fb..851706f 100644 --- a/apps/dashboard/src/lib/urls.ts +++ b/apps/dashboard/src/lib/urls.ts @@ -1,17 +1,18 @@ import { resolveBrowserAppUrl } from '@/lib/appUrls' -function toAppOrigin(url: string): string { +function toAppBase(url: string): string { try { - return new URL(url).origin + const u = new URL(url) + return (u.origin + u.pathname).replace(/\/$/, '') } catch { return url.replace(/\/$/, '') } } -export const marketplaceUrl = toAppOrigin( - resolveBrowserAppUrl(process.env.NEXT_PUBLIC_MARKETPLACE_URL ?? 'http://localhost:3000'), +export const marketplaceUrl = toAppBase( + resolveBrowserAppUrl(process.env.NEXT_PUBLIC_MARKETPLACE_URL ?? 'http://localhost:3000/marketplace'), ) -export const adminUrl = toAppOrigin( - resolveBrowserAppUrl(process.env.NEXT_PUBLIC_ADMIN_URL ?? 'http://localhost:3002'), +export const adminUrl = toAppBase( + resolveBrowserAppUrl(process.env.NEXT_PUBLIC_ADMIN_URL ?? 'http://localhost:3002/admin'), ) diff --git a/apps/dashboard/src/middleware.ts b/apps/dashboard/src/middleware.ts index 7bff243..c0034cb 100644 --- a/apps/dashboard/src/middleware.ts +++ b/apps/dashboard/src/middleware.ts @@ -11,7 +11,8 @@ function localJwtMiddleware(req: NextRequest): NextResponse { // Check for employee_token cookie (set on login) OR allow if coming from sign-in const token = req.cookies.get('employee_token')?.value if (!token) { - const signInUrl = new URL('/sign-in', req.url) + const signInUrl = req.nextUrl.clone() + signInUrl.pathname = '/sign-in' signInUrl.searchParams.set('redirect', req.nextUrl.pathname) return NextResponse.redirect(signInUrl) } diff --git a/apps/marketplace/next.config.js b/apps/marketplace/next.config.js index 4f89111..0ec172c 100644 --- a/apps/marketplace/next.config.js +++ b/apps/marketplace/next.config.js @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + basePath: '/marketplace', images: { domains: ['res.cloudinary.com'], }, diff --git a/docker-compose.production.yml b/docker-compose.production.yml index c502a71..f2d69b9 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -84,30 +84,34 @@ services: restart: unless-stopped labels: - traefik.enable=true - # public site (port 3003) — owns both bare and www domains - - traefik.http.routers.public-site.rule=Host(`${PUBLIC_SITE_DOMAIN}`) || Host(`www.${PUBLIC_SITE_DOMAIN}`) - - traefik.http.routers.public-site.entrypoints=websecure - - traefik.http.routers.public-site.tls.certresolver=letsencrypt - - traefik.http.routers.public-site.service=public-site-svc - - traefik.http.services.public-site-svc.loadbalancer.server.port=3003 - # marketplace (port 3000) — should use its own subdomain - - traefik.http.routers.marketplace.rule=Host(`${MARKETPLACE_DOMAIN}`) + # marketplace (port 3000) — /marketplace path, priority 20 + - traefik.http.routers.marketplace.rule=Host(`${PUBLIC_SITE_DOMAIN}`) && PathPrefix(`/marketplace`) + - traefik.http.routers.marketplace.priority=20 - traefik.http.routers.marketplace.entrypoints=websecure - traefik.http.routers.marketplace.tls.certresolver=letsencrypt - traefik.http.routers.marketplace.service=marketplace-svc - traefik.http.services.marketplace-svc.loadbalancer.server.port=3000 - # admin (port 3002) - - traefik.http.routers.admin.rule=Host(`${ADMIN_DOMAIN}`) - - traefik.http.routers.admin.entrypoints=websecure - - traefik.http.routers.admin.tls.certresolver=letsencrypt - - traefik.http.routers.admin.service=admin-svc - - traefik.http.services.admin-svc.loadbalancer.server.port=3002 - # dashboard (port 3001) - - traefik.http.routers.dashboard.rule=Host(`${DASHBOARD_DOMAIN}`) + # dashboard (port 3001) — /dashboard path, priority 20 + - traefik.http.routers.dashboard.rule=Host(`${PUBLIC_SITE_DOMAIN}`) && PathPrefix(`/dashboard`) + - traefik.http.routers.dashboard.priority=20 - traefik.http.routers.dashboard.entrypoints=websecure - traefik.http.routers.dashboard.tls.certresolver=letsencrypt - traefik.http.routers.dashboard.service=dashboard-svc - traefik.http.services.dashboard-svc.loadbalancer.server.port=3001 + # admin (port 3002) — /admin path, priority 20 + - traefik.http.routers.admin.rule=Host(`${PUBLIC_SITE_DOMAIN}`) && PathPrefix(`/admin`) + - traefik.http.routers.admin.priority=20 + - traefik.http.routers.admin.entrypoints=websecure + - traefik.http.routers.admin.tls.certresolver=letsencrypt + - traefik.http.routers.admin.service=admin-svc + - traefik.http.services.admin-svc.loadbalancer.server.port=3002 + # public site (port 3003) — root domain + tenant subdomains, priority 10 + - traefik.http.routers.public-site.rule=Host(`${PUBLIC_SITE_DOMAIN}`) || Host(`www.${PUBLIC_SITE_DOMAIN}`) || HostRegexp(`{subdomain:[a-z0-9-]+}.${PUBLIC_SITE_DOMAIN}`) + - traefik.http.routers.public-site.priority=10 + - traefik.http.routers.public-site.entrypoints=websecure + - traefik.http.routers.public-site.tls.certresolver=letsencrypt + - traefik.http.routers.public-site.service=public-site-svc + - traefik.http.services.public-site-svc.loadbalancer.server.port=3003 pgmanage: image: cmdpromptinc/pgmanage-enterprise:latest