Compare commits
6 Commits
v1.2.11-rc
...
v1.2.12
| Author | SHA1 | Date | |
|---|---|---|---|
| 9de3931e33 | |||
| b10dbcb23f | |||
| 65bb9c620a | |||
| 63853ffa89 | |||
| 9694c77ef7 | |||
| 2c11b5026a |
@@ -1,5 +1,15 @@
|
|||||||
node_modules
|
node_modules
|
||||||
.next
|
.next
|
||||||
|
.DS_Store
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitea
|
||||||
|
.github
|
||||||
|
public/uploads
|
||||||
|
directus/uploads
|
||||||
|
.turbo
|
||||||
|
reference/
|
||||||
|
.next
|
||||||
!.next/cache
|
!.next/cache
|
||||||
.git
|
.git
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@@ -46,8 +46,19 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
NPM_TOKEN: ${{ secrets.REGISTRY_PASS }}
|
NPM_TOKEN: ${{ secrets.REGISTRY_PASS }}
|
||||||
|
|
||||||
|
- name: Setup Turbo cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-${{ github.ref_name }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-turbo-${{ github.ref_name }}-
|
||||||
|
${{ runner.os }}-turbo-
|
||||||
|
|
||||||
- name: 🧪 QA Checks
|
- name: 🧪 QA Checks
|
||||||
run: pnpm check:mdx && pnpm lint && pnpm typecheck && pnpm test
|
env:
|
||||||
|
TURBO_TELEMETRY_DISABLED: "1"
|
||||||
|
run: npx turbo run check:mdx lint typecheck test --cache-dir=".turbo"
|
||||||
|
|
||||||
- name: 🏗️ Build
|
- name: 🏗️ Build
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
|
|||||||
@@ -171,15 +171,22 @@ jobs:
|
|||||||
echo "//${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}/:_authToken=${{ secrets.REGISTRY_PASS }}" >> .npmrc
|
echo "//${{ vars.REGISTRY_HOST || 'npm.infra.mintel.me' }}/:_authToken=${{ secrets.REGISTRY_PASS }}" >> .npmrc
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
- name: Setup Turbo cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-${{ github.ref_name }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-turbo-${{ github.ref_name }}-
|
||||||
|
${{ runner.os }}-turbo-
|
||||||
|
|
||||||
- name: 🔒 Security Audit
|
- name: 🔒 Security Audit
|
||||||
run: pnpm audit --audit-level high
|
run: pnpm audit --audit-level high
|
||||||
- name: 🧪 QA Checks
|
- name: 🧪 QA Checks
|
||||||
if: github.event.inputs.skip_checks != 'true'
|
if: github.event.inputs.skip_checks != 'true'
|
||||||
run: |
|
env:
|
||||||
pnpm lint
|
TURBO_TELEMETRY_DISABLED: "1"
|
||||||
pnpm check:spell
|
run: npx turbo run lint check:spell typecheck test --cache-dir=".turbo"
|
||||||
pnpm typecheck
|
|
||||||
pnpm test
|
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
# JOB 3: Build & Push
|
# JOB 3: Build & Push
|
||||||
@@ -205,6 +212,8 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
provenance: false
|
provenance: false
|
||||||
platforms: linux/arm64
|
platforms: linux/arm64
|
||||||
|
cache-from: type=gha,scope=nextjs-build-${{ needs.prepare.outputs.target }}
|
||||||
|
cache-to: type=gha,mode=max,scope=nextjs-build-${{ needs.prepare.outputs.target }}
|
||||||
build-args: |
|
build-args: |
|
||||||
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_url }}
|
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_url }}
|
||||||
NEXT_PUBLIC_TARGET=${{ needs.prepare.outputs.target }}
|
NEXT_PUBLIC_TARGET=${{ needs.prepare.outputs.target }}
|
||||||
|
|||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -20,3 +20,10 @@ directus/uploads
|
|||||||
.pa11yci/
|
.pa11yci/
|
||||||
|
|
||||||
.htmlvalidate-tmp
|
.htmlvalidate-tmp
|
||||||
|
|
||||||
|
# Turborepo
|
||||||
|
.turbo
|
||||||
|
|
||||||
|
# Test Outputs
|
||||||
|
html-errors*.json
|
||||||
|
reference/
|
||||||
@@ -41,7 +41,10 @@ CMD ["pnpm", "dev:local"]
|
|||||||
# Build application
|
# Build application
|
||||||
# Stage 3: Builder (Production)
|
# Stage 3: Builder (Production)
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
RUN pnpm build
|
RUN --mount=type=cache,target=/app/.next/cache,id=nextjs-cache \
|
||||||
|
pnpm build && \
|
||||||
|
mkdir -p /app/.next-cache-tmp && \
|
||||||
|
cp -r /app/.next/cache/* /app/.next-cache-tmp/ || true
|
||||||
|
|
||||||
# Stage 3: Runner
|
# Stage 3: Runner
|
||||||
FROM registry.infra.mintel.me/mintel/runtime:v1.7.10 AS runner
|
FROM registry.infra.mintel.me/mintel/runtime:v1.7.10 AS runner
|
||||||
@@ -60,6 +63,6 @@ ENV NODE_ENV=production
|
|||||||
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
COPY --from=builder --chown=nextjs:nodejs /app/.next-cache-tmp ./.next/cache
|
||||||
|
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ services:
|
|||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
environment:
|
environment:
|
||||||
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
|
OPENROUTER_API_KEY: ${OPENROUTER_API_KEY}
|
||||||
# IMGPROXY_URL_MAPPING is not used by our new service yet, but we can keep it for future parity if we add it back
|
# explicitly map localhost, production and staging to bypass gatekeeper
|
||||||
IMGPROXY_URL_MAPPING: "${NEXT_PUBLIC_BASE_URL}:http://klz-app:3000,${DIRECTUS_URL}:http://klz-cms:8055"
|
IMGPROXY_URL_MAPPING: "https://staging.klz-cables.com:http://klz-app:3000,https://klz-cables.com:http://klz-app:3000,https://${TRAEFIK_HOST:-klz.localhost}:http://klz-app:3000,${DIRECTUS_URL}:http://klz-cms:8055,https://cms.klz-cables.com:http://klz-cms:8055"
|
||||||
IMGPROXY_LOG_LEVEL: debug
|
IMGPROXY_LOG_LEVEL: debug
|
||||||
|
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
@@ -10,10 +10,38 @@ const intlMiddleware = createMiddleware({
|
|||||||
defaultLocale: 'en',
|
defaultLocale: 'en',
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function middleware(request: NextRequest) {
|
const imgproxyStatus = { isDown: false, lastCheck: 0 };
|
||||||
|
|
||||||
|
async function isImgproxyDown() {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - imgproxyStatus.lastCheck > 60000) {
|
||||||
|
try {
|
||||||
|
const imgproxyUrl = process.env.IMGPROXY_URL || 'https://img.infra.mintel.me';
|
||||||
|
const checkUrl = imgproxyUrl.startsWith('http') ? imgproxyUrl : `https://${imgproxyUrl}`;
|
||||||
|
const res = await fetch(checkUrl, { signal: AbortSignal.timeout(2000) });
|
||||||
|
imgproxyStatus.isDown = res.status >= 500;
|
||||||
|
} catch (e) {
|
||||||
|
imgproxyStatus.isDown = true;
|
||||||
|
}
|
||||||
|
imgproxyStatus.lastCheck = now;
|
||||||
|
}
|
||||||
|
return imgproxyStatus.isDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function middleware(request: NextRequest) {
|
||||||
const { method, url, headers } = request;
|
const { method, url, headers } = request;
|
||||||
const { pathname } = request.nextUrl;
|
const { pathname } = request.nextUrl;
|
||||||
|
|
||||||
|
if (pathname.startsWith('/_img/')) {
|
||||||
|
if (await isImgproxyDown()) {
|
||||||
|
const originalUrl = request.nextUrl.searchParams.get('url');
|
||||||
|
if (originalUrl) {
|
||||||
|
return NextResponse.redirect(originalUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NextResponse.next();
|
||||||
|
}
|
||||||
|
|
||||||
// Explicit bypass for infrastructure routes to avoid locale redirects/interception
|
// Explicit bypass for infrastructure routes to avoid locale redirects/interception
|
||||||
if (
|
if (
|
||||||
pathname.startsWith('/stats') ||
|
pathname.startsWith('/stats') ||
|
||||||
@@ -97,7 +125,7 @@ export default function middleware(request: NextRequest) {
|
|||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: [
|
matcher: [
|
||||||
'/((?!api|_next/static|_next/image|_img|favicon.ico|manifest.webmanifest|.*\\.(?:svg|png|jpg|jpeg|gif|webp|pdf|txt|vcf|xml|webm|mp4|map)$).*)',
|
'/((?!api|_next/static|_next/image|favicon.ico|manifest.webmanifest|.*\\.(?:svg|png|jpg|jpeg|gif|webp|pdf|txt|vcf|xml|webm|mp4|map)$).*)',
|
||||||
'/(de|en)/:path*',
|
'/(de|en)/:path*',
|
||||||
'/(de|en)/:path*',
|
'/(de|en)/:path*',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"name": "klz-cables-nextjs",
|
"name": "klz-cables-nextjs",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"packageManager": "pnpm@10.18.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@directus/sdk": "^21.0.0",
|
"@directus/sdk": "^21.0.0",
|
||||||
"@mintel/mail": "1.8.3",
|
"@mintel/mail": "1.8.3",
|
||||||
@@ -79,6 +80,7 @@
|
|||||||
"start-server-and-test": "^2.1.3",
|
"start-server-and-test": "^2.1.3",
|
||||||
"tailwindcss": "^4.1.18",
|
"tailwindcss": "^4.1.18",
|
||||||
"tsx": "^4.21.0",
|
"tsx": "^4.21.0",
|
||||||
|
"turbo": "^2.8.10",
|
||||||
"typescript": "^5.7.2",
|
"typescript": "^5.7.2",
|
||||||
"vitest": "^4.0.16"
|
"vitest": "^4.0.16"
|
||||||
},
|
},
|
||||||
@@ -124,7 +126,7 @@
|
|||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"preinstall": "npx only-allow pnpm"
|
"preinstall": "npx only-allow pnpm"
|
||||||
},
|
},
|
||||||
"version": "1.0.0",
|
"version": "1.0.1-rc.0",
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"next": "16.1.6",
|
"next": "16.1.6",
|
||||||
|
|||||||
64
pnpm-lock.yaml
generated
64
pnpm-lock.yaml
generated
@@ -235,6 +235,9 @@ importers:
|
|||||||
tsx:
|
tsx:
|
||||||
specifier: ^4.21.0
|
specifier: ^4.21.0
|
||||||
version: 4.21.0
|
version: 4.21.0
|
||||||
|
turbo:
|
||||||
|
specifier: ^2.8.10
|
||||||
|
version: 2.8.10
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.7.2
|
specifier: ^5.7.2
|
||||||
version: 5.9.3
|
version: 5.9.3
|
||||||
@@ -7166,6 +7169,40 @@ packages:
|
|||||||
engines: {node: '>=18.0.0'}
|
engines: {node: '>=18.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
turbo-darwin-64@2.8.10:
|
||||||
|
resolution: {integrity: sha512-A03fXh+B7S8mL3PbdhTd+0UsaGrhfyPkODvzBDpKRY7bbeac4MDFpJ7I+Slf2oSkCEeSvHKR7Z4U71uKRUfX7g==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
turbo-darwin-arm64@2.8.10:
|
||||||
|
resolution: {integrity: sha512-sidzowgWL3s5xCHLeqwC9M3s9M0i16W1nuQF3Mc7fPHpZ+YPohvcbVFBB2uoRRHYZg6yBnwD4gyUHKTeXfwtXA==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [darwin]
|
||||||
|
|
||||||
|
turbo-linux-64@2.8.10:
|
||||||
|
resolution: {integrity: sha512-YK9vcpL3TVtqonB021XwgaQhY9hJJbKKUhLv16osxV0HkcQASQWUqR56yMge7puh6nxU67rQlTq1b7ksR1T3KA==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
turbo-linux-arm64@2.8.10:
|
||||||
|
resolution: {integrity: sha512-3+j2tL0sG95iBJTm+6J8/45JsETQABPqtFyYjVjBbi6eVGdtNTiBmHNKrbvXRlQ3ZbUG75bKLaSSDHSEEN+btQ==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
turbo-windows-64@2.8.10:
|
||||||
|
resolution: {integrity: sha512-hdeF5qmVY/NFgiucf8FW0CWJWtyT2QPm5mIsX0W1DXAVzqKVXGq+Zf+dg4EUngAFKjDzoBeN6ec2Fhajwfztkw==}
|
||||||
|
cpu: [x64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
turbo-windows-arm64@2.8.10:
|
||||||
|
resolution: {integrity: sha512-QGdr/Q8LWmj+ITMkSvfiz2glf0d7JG0oXVzGL3jxkGqiBI1zXFj20oqVY0qWi+112LO9SVrYdpHS0E/oGFrMbQ==}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [win32]
|
||||||
|
|
||||||
|
turbo@2.8.10:
|
||||||
|
resolution: {integrity: sha512-OxbzDES66+x7nnKGg2MwBA1ypVsZoDTLHpeaP4giyiHSixbsiTaMyeJqbEyvBdp5Cm28fc+8GG6RdQtic0ijwQ==}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
type-check@0.4.0:
|
type-check@0.4.0:
|
||||||
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
@@ -15498,6 +15535,33 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
fsevents: 2.3.3
|
fsevents: 2.3.3
|
||||||
|
|
||||||
|
turbo-darwin-64@2.8.10:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
turbo-darwin-arm64@2.8.10:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
turbo-linux-64@2.8.10:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
turbo-linux-arm64@2.8.10:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
turbo-windows-64@2.8.10:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
turbo-windows-arm64@2.8.10:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
turbo@2.8.10:
|
||||||
|
optionalDependencies:
|
||||||
|
turbo-darwin-64: 2.8.10
|
||||||
|
turbo-darwin-arm64: 2.8.10
|
||||||
|
turbo-linux-64: 2.8.10
|
||||||
|
turbo-linux-arm64: 2.8.10
|
||||||
|
turbo-windows-64: 2.8.10
|
||||||
|
turbo-windows-arm64: 2.8.10
|
||||||
|
|
||||||
type-check@0.4.0:
|
type-check@0.4.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
prelude-ls: 1.2.1
|
prelude-ls: 1.2.1
|
||||||
|
|||||||
20
turbo.json
Normal file
20
turbo.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://turbo.build/schema.json",
|
||||||
|
"tasks": {
|
||||||
|
"lint": {
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
"typecheck": {
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
"check:spell": {
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
"check:mdx": {
|
||||||
|
"outputs": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user