mirror of
https://github.com/luxfi/explore.git
synced 2026-07-27 03:13:50 +00:00
- LatestBlocks: full-width layout instead of fixed 280px sidebar - Stats: 4-column grid on desktop, 2-column on mobile - NetworkOverview: fallback known L1 chains when P-chain API unreachable - NetworkOverview: expose isError from useCurrentValidators - P-chain hooks: add retry:2 for resilience - UserProfile: use address_hash instead of id for display - Replace middleware.ts with proxy.ts (unused in production Docker) - Add toolkit/chakra/separator re-export - tsconfig: jsx react-jsx, formatting cleanup - dev.sh: disable turbopack (stability)
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import type { NextRequest } from 'next/server';
|
|
import { NextResponse } from 'next/server';
|
|
|
|
import * as csp from 'nextjs/csp/index';
|
|
import * as middlewares from 'nextjs/middlewares/index';
|
|
|
|
export async function proxy(req: NextRequest) {
|
|
const isPageRequest = req.headers.get('accept')?.includes('text/html');
|
|
const start = Date.now();
|
|
|
|
if (!isPageRequest) {
|
|
return;
|
|
}
|
|
|
|
const accountResponse = middlewares.account(req);
|
|
if (accountResponse) {
|
|
return accountResponse;
|
|
}
|
|
|
|
const res = NextResponse.next();
|
|
|
|
middlewares.appProfile(req, res);
|
|
middlewares.colorTheme(req, res);
|
|
middlewares.addressFormat(req, res);
|
|
middlewares.scamTokens(req, res);
|
|
middlewares.poorReputationTokens(req, res);
|
|
|
|
const end = Date.now();
|
|
|
|
const cspHeader = await csp.get(req);
|
|
|
|
res.headers.append('Content-Security-Policy', cspHeader);
|
|
res.headers.append('Server-Timing', `middleware;dur=${ end - start }`);
|
|
res.headers.append('Docker-ID', process.env.HOSTNAME || '');
|
|
|
|
return res;
|
|
}
|
|
|
|
/**
|
|
* Configure which routes should pass through the Middleware.
|
|
*/
|
|
export const config = {
|
|
matcher: [ '/', '/:notunderscore((?!_next).+)' ],
|
|
// matcher: [
|
|
// '/((?!.*\\.|api\\/|node-api\\/).*)', // exclude all static + api + node-api routes
|
|
// ],
|
|
};
|