Skip to content

Commit 028ec6c

Browse files
Dhruv Jindalbalpreetgrowthnatives
authored andcommitted
chore: add dynamic canonical tags to auth endpoints to fix duplicate SEO errors
1 parent a047c17 commit 028ec6c

4 files changed

Lines changed: 78 additions & 40 deletions

File tree

pages/auth/login.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
import React from "react";
2-
import SignIn from "../../components/AuthUI/AuthUI";
1+
import Head from 'next/head'
2+
import { useRouter } from 'next/router'
3+
import React from 'react'
4+
import SignIn from '../../components/AuthUI/AuthUI'
5+
import { SITE_URL } from '../../src/constants'
36

47
const SignInPage: React.FC = () => {
8+
const router = useRouter()
9+
const localePrefix =
10+
router.locale === router.defaultLocale ? '' : `/${router.locale}`
11+
const canonicalUrl = `${SITE_URL}${localePrefix}${router.pathname}`
12+
513
return (
614
<>
15+
<Head>
16+
<link rel="canonical" href={canonicalUrl} />
17+
</Head>
718
<SignIn />
819
</>
9-
);
10-
};
11-
export default SignInPage;
20+
)
21+
}
22+
export default SignInPage

pages/auth/logout.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
import React from "react";
2-
import Logout from "../../components/AuthUI/Logout";
1+
import Head from 'next/head'
2+
import { useRouter } from 'next/router'
3+
import React from 'react'
4+
import Logout from '../../components/AuthUI/Logout'
5+
import { SITE_URL } from '../../src/constants'
36

47
const LogoutPage: React.FC = () => {
8+
const router = useRouter()
9+
const localePrefix =
10+
router.locale === router.defaultLocale ? '' : `/${router.locale}`
11+
const canonicalUrl = `${SITE_URL}${localePrefix}${router.pathname}`
12+
513
return (
614
<>
15+
<Head>
16+
<link rel="canonical" href={canonicalUrl} />
17+
</Head>
718
<Logout />
819
</>
9-
);
10-
};
11-
export default LogoutPage;
20+
)
21+
}
22+
export default LogoutPage

pages/auth/signup.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
import React from "react";
2-
import SignIn from "../../components/AuthUI/AuthUI";
1+
import Head from 'next/head'
2+
import { useRouter } from 'next/router'
3+
import React from 'react'
4+
import SignIn from '../../components/AuthUI/AuthUI'
5+
import { SITE_URL } from '../../src/constants'
36

47
const SignUpPage: React.FC = () => {
8+
const router = useRouter()
9+
const localePrefix =
10+
router.locale === router.defaultLocale ? '' : `/${router.locale}`
11+
const canonicalUrl = `${SITE_URL}${localePrefix}${router.pathname}`
12+
513
return (
614
<>
15+
<Head>
16+
<link rel="canonical" href={canonicalUrl} />
17+
</Head>
718
<SignIn />
819
</>
9-
);
10-
};
11-
export default SignUpPage;
20+
)
21+
}
22+
export default SignUpPage

src/constants.ts

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1-
export const INSTANT_SEARCH_INDEX_NAME = "nodes_index";
2-
export const INSTANT_SEARCH_QUERY_SUGGESTIONS = "nodes_index_query_suggestions";
1+
export const INSTANT_SEARCH_INDEX_NAME = 'nodes_index'
2+
export const INSTANT_SEARCH_QUERY_SUGGESTIONS = 'nodes_index_query_suggestions'
33
export const INSTANT_SEARCH_HIERARCHICAL_ATTRIBUTES = [
4-
"hierarchicalCategories.lvl0",
5-
"hierarchicalCategories.lvl1",
6-
];
4+
'hierarchicalCategories.lvl0',
5+
'hierarchicalCategories.lvl1',
6+
]
77

8-
export const UNCLAIMED_ADMIN_PUBLISHER_ID = "admin-11338bd3-f081-43cf-b3f9-295c829826f7"; // copy from https://github.com/Comfy-Org/comfy-api/blob/main/db/publisher.go#L13
8+
export const UNCLAIMED_ADMIN_PUBLISHER_ID =
9+
'admin-11338bd3-f081-43cf-b3f9-295c829826f7' // copy from https://github.com/Comfy-Org/comfy-api/blob/main/db/publisher.go#L13
910

1011
// Storage key for language preference
11-
export const LANGUAGE_STORAGE_KEY = "comfy-registry-language-preference" as const;
12+
export const LANGUAGE_STORAGE_KEY =
13+
'comfy-registry-language-preference' as const
1214

1315
// Language configuration
14-
export const DEFAULT_LANGUAGE = "en";
16+
export const DEFAULT_LANGUAGE = 'en'
1517

1618
const LANGUAGE_NAMES = {
17-
en: "English",
18-
zh: "中文",
19-
ja: "日本語",
20-
fr: "Français",
21-
es: "Español",
22-
ko: "한국어",
23-
ru: "Русский",
24-
ar: "العربية",
25-
tr: "Türkçe",
26-
};
19+
en: 'English',
20+
zh: '中文',
21+
ja: '日本語',
22+
fr: 'Français',
23+
es: 'Español',
24+
ko: '한국어',
25+
ru: 'Русский',
26+
ar: 'العربية',
27+
tr: 'Türkçe',
28+
}
2729

2830
export const SUPPORTED_LANGUAGES = Object.keys(LANGUAGE_NAMES) as Array<
2931
keyof typeof LANGUAGE_NAMES
30-
>;
31-
export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
32+
>
33+
export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number]
3234

3335
// HTTP Cache Control Headers
3436
export const NO_CACHE_HEADERS = {
35-
"Cache-Control": "no-cache, no-store, must-revalidate",
36-
Pragma: "no-cache",
37-
Expires: "0",
38-
} as const;
37+
'Cache-Control': 'no-cache, no-store, must-revalidate',
38+
Pragma: 'no-cache',
39+
Expires: '0',
40+
} as const
3941

4042
// Type for request options with no-cache headers
4143
export const REQUEST_OPTIONS_NO_CACHE = {
4244
headers: NO_CACHE_HEADERS,
43-
} as const;
45+
} as const
46+
47+
export const SITE_URL =
48+
process.env.NEXT_PUBLIC_SITE_URL || 'https://registry.comfy.org'

0 commit comments

Comments
 (0)