refactor(middleware): upgrade locale redirects from 307 to 308 for better scanner compatibility
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 13s
Build & Deploy / 🧪 QA (push) Failing after 54s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s

This commit is contained in:
2026-02-16 18:45:33 +01:00
parent c0f5799667
commit 848d58010f

View File

@@ -62,6 +62,17 @@ export default function middleware(request: NextRequest) {
try {
// Apply internationalization middleware
const response = intlMiddleware(effectiveRequest);
// Upgrade 307 (Temporary Redirect) to 308 (Permanent Redirect)
// This improves compatibility with scanners (Website Carbon, PageSpeed) and SEO.
if (response.status === 307) {
const location = response.headers.get('Location');
if (location) {
const url = new URL(location, request.url);
return Response.redirect(url, 308);
}
}
return response;
} catch (error) {
console.error(