feat: Enhance Directus URL resolution for internal and proxy paths, and adjust Traefik host variable interpolation.
Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 39s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m33s
Build & Deploy KLZ Cables / 🏗️ Build Gatekeeper (push) Successful in 22s
Build & Deploy KLZ Cables / 🏗️ Build App (push) Successful in 4m47s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Successful in 48s
Build & Deploy KLZ Cables / ⚡ PageSpeed (push) Failing after 3m50s
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 2s
Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 39s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m33s
Build & Deploy KLZ Cables / 🏗️ Build Gatekeeper (push) Successful in 22s
Build & Deploy KLZ Cables / 🏗️ Build App (push) Successful in 4m47s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Successful in 48s
Build & Deploy KLZ Cables / ⚡ PageSpeed (push) Failing after 3m50s
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 2s
This commit is contained in:
@@ -89,10 +89,10 @@ jobs:
|
|||||||
TARGET="testing"
|
TARGET="testing"
|
||||||
IMAGE_TAG="main-${SHORT_SHA}"
|
IMAGE_TAG="main-${SHORT_SHA}"
|
||||||
ENV_FILE=".env.testing"
|
ENV_FILE=".env.testing"
|
||||||
TRAEFIK_HOST='`testing.klz-cables.com`'
|
TRAEFIK_HOST="testing.klz-cables.com"
|
||||||
NEXT_PUBLIC_BASE_URL="https://testing.klz-cables.com"
|
NEXT_PUBLIC_BASE_URL="https://testing.klz-cables.com"
|
||||||
DIRECTUS_URL="https://cms.testing.klz-cables.com"
|
DIRECTUS_URL="https://cms.testing.klz-cables.com"
|
||||||
DIRECTUS_HOST='`cms.testing.klz-cables.com`'
|
DIRECTUS_HOST="cms.testing.klz-cables.com"
|
||||||
PROJECT_NAME="klz-cables-testing"
|
PROJECT_NAME="klz-cables-testing"
|
||||||
IS_PROD="false"
|
IS_PROD="false"
|
||||||
GOTIFY_TITLE="🧪 Testing-Deploy"
|
GOTIFY_TITLE="🧪 Testing-Deploy"
|
||||||
@@ -103,10 +103,10 @@ jobs:
|
|||||||
TARGET="production"
|
TARGET="production"
|
||||||
IMAGE_TAG="$TAG"
|
IMAGE_TAG="$TAG"
|
||||||
ENV_FILE=".env.prod"
|
ENV_FILE=".env.prod"
|
||||||
TRAEFIK_HOST='`klz-cables.com`, `www.klz-cables.com`'
|
TRAEFIK_HOST="klz-cables.com, www.klz-cables.com"
|
||||||
NEXT_PUBLIC_BASE_URL="https://klz-cables.com"
|
NEXT_PUBLIC_BASE_URL="https://klz-cables.com"
|
||||||
DIRECTUS_URL="https://cms.klz-cables.com"
|
DIRECTUS_URL="https://cms.klz-cables.com"
|
||||||
DIRECTUS_HOST='`cms.klz-cables.com`'
|
DIRECTUS_HOST="cms.klz-cables.com"
|
||||||
PROJECT_NAME="klz-cables-prod"
|
PROJECT_NAME="klz-cables-prod"
|
||||||
IS_PROD="true"
|
IS_PROD="true"
|
||||||
GOTIFY_TITLE="🚀 Production-Release"
|
GOTIFY_TITLE="🚀 Production-Release"
|
||||||
@@ -115,10 +115,10 @@ jobs:
|
|||||||
TARGET="staging"
|
TARGET="staging"
|
||||||
IMAGE_TAG="$TAG"
|
IMAGE_TAG="$TAG"
|
||||||
ENV_FILE=".env.staging"
|
ENV_FILE=".env.staging"
|
||||||
TRAEFIK_HOST='`staging.klz-cables.com`'
|
TRAEFIK_HOST="staging.klz-cables.com"
|
||||||
NEXT_PUBLIC_BASE_URL="https://staging.klz-cables.com"
|
NEXT_PUBLIC_BASE_URL="https://staging.klz-cables.com"
|
||||||
DIRECTUS_URL="https://cms.staging.klz-cables.com"
|
DIRECTUS_URL="https://cms.staging.klz-cables.com"
|
||||||
DIRECTUS_HOST='`cms.staging.klz-cables.com`'
|
DIRECTUS_HOST="cms.staging.klz-cables.com"
|
||||||
PROJECT_NAME="klz-cables-staging"
|
PROJECT_NAME="klz-cables-staging"
|
||||||
IS_PROD="false"
|
IS_PROD="false"
|
||||||
GOTIFY_TITLE="🧪 Staging-Deploy (Pre-Release)"
|
GOTIFY_TITLE="🧪 Staging-Deploy (Pre-Release)"
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
# HTTP ⇒ HTTPS redirect
|
# HTTP ⇒ HTTPS redirect
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.rule=Host(${TRAEFIK_HOST}) && !PathPrefix(`/.well-known/acme-challenge/`)"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.rule=Host(`${TRAEFIK_HOST}`) && !PathPrefix(`/.well-known/acme-challenge/`)"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.entrypoints=web"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.entrypoints=web"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.middlewares=redirect-https"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.middlewares=redirect-https"
|
||||||
# HTTPS router
|
# HTTPS router
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.rule=Host(${TRAEFIK_HOST})"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.rule=Host(`${TRAEFIK_HOST}`)"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.entrypoints=websecure"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.entrypoints=websecure"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls.certresolver=le"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls.certresolver=le"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls=true"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls=true"
|
||||||
@@ -43,7 +43,7 @@ services:
|
|||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.middlewares=${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${AUTH_MIDDLEWARE:-compress}"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}.middlewares=${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${AUTH_MIDDLEWARE:-compress}"
|
||||||
|
|
||||||
# Gatekeeper Router (to show the login page)
|
# Gatekeeper Router (to show the login page)
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.rule=Host(${TRAEFIK_HOST}) && PathPrefix(`/gatekeeper`)"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.rule=Host(`${TRAEFIK_HOST}`) && PathPrefix(`/gatekeeper`)"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.entrypoints=websecure"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.entrypoints=websecure"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls.certresolver=le"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls.certresolver=le"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls=true"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls=true"
|
||||||
@@ -102,7 +102,7 @@ services:
|
|||||||
- ./directus/extensions:/directus/extensions
|
- ./directus/extensions:/directus/extensions
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.rule=Host(${DIRECTUS_HOST})"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.rule=Host(`${DIRECTUS_HOST}`)"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.entrypoints=websecure"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.entrypoints=websecure"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.tls.certresolver=le"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.tls.certresolver=le"
|
||||||
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.tls=true"
|
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.tls=true"
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ import { getServerAppServices } from './services/create-services.server';
|
|||||||
const { url, adminEmail, password, token, proxyPath, internalUrl } = config.directus;
|
const { url, adminEmail, password, token, proxyPath, internalUrl } = config.directus;
|
||||||
|
|
||||||
// Use internal URL if on server to bypass Gatekeeper/Auth
|
// Use internal URL if on server to bypass Gatekeeper/Auth
|
||||||
const effectiveUrl = typeof window === 'undefined' && internalUrl ? internalUrl : url;
|
// Use proxy path in browser to stay on the same origin
|
||||||
|
const effectiveUrl =
|
||||||
|
typeof window === 'undefined'
|
||||||
|
? internalUrl || url
|
||||||
|
: typeof window !== 'undefined'
|
||||||
|
? `${window.location.origin}${proxyPath}`
|
||||||
|
: proxyPath;
|
||||||
|
|
||||||
const client = createDirectus(effectiveUrl).with(rest()).with(authentication());
|
const client = createDirectus(effectiveUrl).with(rest()).with(authentication());
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const intlMiddleware = createMiddleware({
|
|||||||
locales: ['en', 'de'],
|
locales: ['en', 'de'],
|
||||||
|
|
||||||
// Used when no locale matches
|
// Used when no locale matches
|
||||||
defaultLocale: 'en'
|
defaultLocale: 'en',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Main middleware that logs all requests
|
// Main middleware that logs all requests
|
||||||
@@ -20,7 +20,7 @@ export default function middleware(request: NextRequest) {
|
|||||||
const ip = headers.get('x-forwarded-for') || headers.get('x-real-ip') || 'unknown';
|
const ip = headers.get('x-forwarded-for') || headers.get('x-real-ip') || 'unknown';
|
||||||
|
|
||||||
// Log incoming request
|
// Log incoming request
|
||||||
console.log(`Incoming request: method=${method} url=${url}`);
|
console.log(`Incoming request: method=${method} host=${headers.get('host')} url=${url}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Apply internationalization middleware
|
// Apply internationalization middleware
|
||||||
@@ -34,5 +34,5 @@ export default function middleware(request: NextRequest) {
|
|||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
// Match only internationalized pathnames
|
// Match only internationalized pathnames
|
||||||
matcher: ['/((?!api|_next|_vercel|health|.*\\..*).*)', '/', '/(de|en)/:path*']
|
matcher: ['/((?!api|_next|_vercel|health|.*\\..*).*)', '/', '/(de|en)/:path*'],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ const nextConfig = {
|
|||||||
? new URL(process.env.SENTRY_DSN).origin
|
? new URL(process.env.SENTRY_DSN).origin
|
||||||
: 'https://errors.infra.mintel.me';
|
: 'https://errors.infra.mintel.me';
|
||||||
|
|
||||||
const directusUrl = process.env.DIRECTUS_URL || 'https://cms.klz-cables.com';
|
const directusUrl = process.env.INTERNAL_DIRECTUS_URL || process.env.DIRECTUS_URL || 'https://cms.klz-cables.com';
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user