Une collection organisée de snippets de code pour accélérer votre développement. Parcourez, recherchez et copiez en un clic.
// middleware.js (à la racine)
import { NextResponse } from 'next/server';
export function middleware(request) {
if (request.nextUrl.pathname.startsWith('/dashboard')) {
return NextResponse.rewrite(new URL('/login', request.url));
}
}
export const config = {
matcher: '/about/:path*',
};
async redirects() {
return [
{
source: '/about-us',
destination: '/about',
permanent: true,
},
];
}
async rewrites() {
return [
{
source: '/api/:path*',
destination: 'https://example.com/api/:path*',
},
];
}
const apiKey = process.env.API_KEY;
DB_HOST=localhost
DB_USER=myuser
DB_PASS=mypassword
NEXT_PUBLIC_ANALYTICS_ID=12345