Skip to content

Commit 82bee81

Browse files
committed
fix: redirect from ssr, and add canonical
1 parent 11cbfde commit 82bee81

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/pages/velog/UserPage.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SeriesTab from './tabs/SeriesTab';
99
import AboutTab from './tabs/AboutTab';
1010
import { themedPalette } from '../../lib/styles/themes';
1111
import media from '../../lib/styles/media';
12+
import { Helmet } from 'react-helmet-async';
1213

1314
const UserPageBlock = styled(VelogResponsive)``;
1415

@@ -19,8 +20,12 @@ const UserPage: React.FC<UserPageProps> = ({ match, location }) => {
1920
const { username, tab } = match.params;
2021
window.location.href = `${process.env
2122
.REACT_APP_CLIENT_V3_HOST!}/@${username}/posts`;
23+
2224
return (
2325
<UserPageBlock>
26+
<Helmet>
27+
<link rel="canonical" href={`/@${username}/posts`} />
28+
</Helmet>
2429
<UserProfileContainer username={username} />
2530
<MobileSeparator />
2631
<VelogTab username={username} tab={tab || 'posts'} />

src/server/ssrMiddleware.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { Middleware } from 'koa';
22
import serverRender from './serverRender';
33

44
const ssrMiddleware: Middleware = async (ctx, next) => {
5+
// redirect to v3 for user posts tab
6+
if (/^\/@([a-z0-9]+)$/.test(ctx.path)) {
7+
ctx.redirect(`${ctx.path}/posts`);
8+
return;
9+
}
10+
511
try {
612
const result = await serverRender({
713
url: ctx.url,

0 commit comments

Comments
 (0)