Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/pages/[page].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ export const getStaticPaths = async () => {
};
};

// Every return carries the home page interval on purpose. The framework keys
// refresh timings by route with a trailing /index stripped, so a request for
// /index answered here without an interval overwrote the home page timing and
// the home page then shipped a one-year shared cache header until a restart.
export const getStaticProps: GetStaticProps = async ({ params, locale }) => {
const { page } = params as { page: string };

const map = await getArticleRedirects(locale ?? 'en');

if (page.startsWith('articles/')) {
return { notFound: true };
return { notFound: true, revalidate: 10 };
}

const resolvedNewUrl = map[page];
Expand All @@ -26,10 +30,11 @@ export const getStaticProps: GetStaticProps = async ({ params, locale }) => {
destination: `/${resolvedNewUrl}`,
permanent: true,
},
revalidate: 10,
};
}

return { notFound: true };
return { notFound: true, revalidate: 10 };
};

export default function LegacyRedirectPage() {
Expand Down
9 changes: 5 additions & 4 deletions src/pages/user/[userId]/certificate.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { getCertificate } from '@uxcore/api/uxcat/certificate';
import { GlobalContext } from '@uxcore/components/Context/GlobalContext';
import Spinner from '@uxcore/components/Spinner';
import pageNotFoundData from '@uxcore/data/404';
import CertificateLayout from '@uxcore/layouts/CertificateLayout';
import type { TRouter } from '@uxcore/local-types/global';
import { useRouter } from 'next/router';
import React, { useContext } from 'react';
import React from 'react';

import NotFoundPage from '../../404';

const Certificate = ({ userId, certificate }) => {
const router = useRouter();
const { locale } = router as TRouter;
const { uxcatUserInfo } = useContext(GlobalContext);

// One holder asked for the full legal name on the certificate. It is tied to
// the certificate's own address, so every viewer reads the same name and no
// other certificate carries it.
const name =
uxcatUserInfo?.user?.id === 1034
String(userId).toLowerCase() === 'tufuka48'
Comment on lines +16 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This puts a private person's full legal name (plus their username) into a public repo. The name stays fetchable by SHA even after a force-push, and this is the pattern the "repository is public" rule in CLAUDE.md warns about. The comparison is also a hardcoded special case in page code.

Better to store the display name in the CMS on the certificate record (e.g. a displayName override) and use certificate?.displayName || \${certificate?.name} ${certificate?.surname}``. That way no personal data lives in the tree. If the name must stay in code for now, it still needs to come out of the git history before this merges.

Also, certificate can be null here, so the fallback renders "undefined undefined" before the 404 branch. That's harmless today because of the early return, but it is cleaner to compute name after the !certificate check.

? 'Кузнецов Тимофей Юрьевич'
: `${certificate?.name} ${certificate?.surname}`;
const date = new Date(certificate?.certificatedAt);
Expand Down
4 changes: 3 additions & 1 deletion src/pages/uxcore-api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const API: FC<ApiProps> = ({ mainSeo }) => {
};
export const getStaticProps: GetStaticProps = async () => {
const mainSeo = await getUXCoreApiSeo();
return { props: { mainSeo } };
// Without an interval the HTML ships a one-year shared cache header and a
// CDN keeps serving it across releases, pointing at assets that are gone.
return { props: { mainSeo }, revalidate: 60 };
};

export default API;
Loading