Files
pakketpunten/webapp/middleware.ts
T
robbertjanssen85andClaude 8617c536ab Disable middleware gzip rewrite to fix GeoJSON loading on Vercel
The middleware was trying to rewrite .geojson requests to .geojson.gz files,
which doesn't work correctly on Vercel with Next.js 16's deprecated middleware.

This was causing "SyntaxError: The string did not match the expected pattern"
errors when loading municipality data.

Solution: Disabled custom gzip serving - Vercel handles compression automatically.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 12:26:36 +01:00

36 lines
1.1 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
export function middleware(request: NextRequest) {
// Middleware disabled - gzip compression handled by Vercel/Next.js automatically
// TODO: Migrate to Next.js 16 proxy configuration when available
// Check if request is for a .geojson file
// if (request.nextUrl.pathname.endsWith('.geojson')) {
// // Check if browser accepts gzip
// const acceptEncoding = request.headers.get('accept-encoding') || '';
//
// if (acceptEncoding.includes('gzip')) {
// // Redirect to .gz version
// const gzPath = request.nextUrl.pathname + '.gz';
// const url = request.nextUrl.clone();
// url.pathname = gzPath;
//
// // Rewrite to .gz file with proper headers
// const response = NextResponse.rewrite(url);
// response.headers.set('Content-Encoding', 'gzip');
// response.headers.set('Content-Type', 'application/geo+json');
//
// return response;
// }
// }
return NextResponse.next();
}
export const config = {
matcher: [
'/data/:path*.geojson',
'/municipalities.json',
],
};