mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* simple fetch data for token instance page * generate enhanced metadata * group query params in page props * make base gSSP function generic * add metric for search engine bots * measure api request duration * get API data for token, address and dapp pages * improve typings for apiData prop * add ENV variable * tweak logs for /media-type requests * [skip ci] add prefix to default metrics
24 lines
750 B
TypeScript
24 lines
750 B
TypeScript
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
|
|
import buildUrl from 'nextjs/utils/buildUrl';
|
|
import fetchFactory from 'nextjs/utils/fetchProxy';
|
|
import { httpLogger } from 'nextjs/utils/logger';
|
|
|
|
export default async function csrfHandler(_req: NextApiRequest, res: NextApiResponse) {
|
|
httpLogger(_req, res);
|
|
|
|
const url = buildUrl('csrf');
|
|
const response = await fetchFactory(_req)(url);
|
|
|
|
if (response.status === 200) {
|
|
const token = response.headers.get('x-bs-account-csrf');
|
|
res.status(200).json({ token });
|
|
return;
|
|
}
|
|
|
|
const responseError = { statusText: response.statusText, status: response.status };
|
|
httpLogger.logger.error({ err: responseError, url: _req.url });
|
|
|
|
res.status(500).json(responseError);
|
|
}
|