Skip to content

Commit 8ba261c

Browse files
committed
www redirects added for robots sitemap and security
1 parent 7c4b75a commit 8ba261c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

web/proxy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export async function proxy(request: NextRequest) {
2626
console.log(request.nextUrl.href)
2727
const pathname = decodeURI(request.nextUrl.pathname)
2828
const isDotHtml = pathname.slice(-5) === DOT_HTML
29+
const isRobotsTxt = pathname.slice(-10) === "robots.txt"
30+
const isSitemapXml = pathname.slice(-11) === "sitemap.xml"
31+
const isSecurityTxt = pathname.slice(-12) === "security.txt"
2932

3033
// Rewrite the correct path for assets in download section of achived news (older than 2016)
3134
if (
@@ -53,7 +56,7 @@ export async function proxy(request: NextRequest) {
5356

5457
// Check if pathname is irrelevant (.svg, .png, /api/, etcs)
5558
if (
56-
(PUBLIC_FILE.test(pathname) && !isDotHtml) ||
59+
(PUBLIC_FILE.test(pathname) && !isDotHtml && !isRobotsTxt && !isSitemapXml && !isSecurityTxt) ||
5760
pathname.includes('/api/')
5861
) {
5962
return undefined

0 commit comments

Comments
 (0)