mirror of
https://github.com/luxfi/explore.git
synced 2026-07-27 05:54:15 +00:00
* context for storing subchain config and tx view for subchain * address page and block page for subchain * address aggregated page: local txs tab * connect MultichainSelect to context * home page placeholder * refactor subchain select state * envs for demo * fix ts * clear value for l2 review * subchain widgets on home page * csp policies * sockets, duck and goose * fix socket on subchain address page * link builder for subchain views * update home widget * fix time increment * enable tx interpretator and metadata service * generate multichain config based on every chain app config * Fix the multichain config to work in Docker * multichain socket test * rename subchain-id to subchain-slug path param * refactoring * update chain icons on entities * home page: latest local txs * latest cross-chain txs * minor improvements * renaming, pt. 1 * rename chain routes * enable blockchain interaction * add loading state to icon shield * fix build * fix tests * update types package
46 lines
1.2 KiB
TypeScript
46 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 middleware(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.colorTheme(req, res);
|
|
middlewares.addressFormat(req, res);
|
|
middlewares.scamTokens(req, res);
|
|
|
|
const end = Date.now();
|
|
|
|
const cspHeader = await csp.get();
|
|
|
|
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
|
|
// ],
|
|
};
|