diff --git a/ecosystem.config.js b/ecosystem.config.js index e48e453a..ad3397f5 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -4,6 +4,7 @@ module.exports = { instances: 2, name: "xlog", script: "./server.js", + max_memory_restart: "4G", }, ], } diff --git a/next.config.js b/next.config.js index f052bf8f..c687222e 100644 --- a/next.config.js +++ b/next.config.js @@ -128,6 +128,31 @@ module.exports = withSentryConfig( ] }, staticPageGenerationTimeout: 3600, + + async redirects() { + return [ + { + source: "/sitemap.txt", + destination: "/sitemap.xml", + permanent: true, + }, + { + source: "/sitemap.xml.gz", + destination: "/sitemap.xml", + permanent: true, + }, + { + source: "/sitemap_index.xml", + destination: "/sitemap.xml", + permanent: true, + }, + { + source: "/sitemaps.xml", + destination: "/sitemap.xml", + permanent: true, + }, + ] + }, }), ), { diff --git a/src/app/site/[site]/sitemap.xml/route.ts b/src/app/site/[site]/sitemap.xml/route.ts index 7b94e94e..82fe4814 100644 --- a/src/app/site/[site]/sitemap.xml/route.ts +++ b/src/app/site/[site]/sitemap.xml/route.ts @@ -37,6 +37,7 @@ export const GET = async (req: NextRequest) => { type: "post", visibility: PageVisibilityEnum.Published, limit: 1000, + skipExpansion: true, }, queryClient, ) diff --git a/src/lib/redis.server.ts b/src/lib/redis.server.ts index d30a162a..4045217a 100644 --- a/src/lib/redis.server.ts +++ b/src/lib/redis.server.ts @@ -49,7 +49,12 @@ export async function cacheGet(options: { } else { redisKey = options.key } - const cacheValue = await redis.get(redisKey) + let cacheValue + try { + cacheValue = await redis.get(redisKey) + } catch (error) { + console.error("Redis get error: ", error) + } if (cacheValue && cacheValue !== "undefined" && cacheValue !== "null") { if (!options.noUpdate) { setTimeout(() => { @@ -71,6 +76,7 @@ export async function cacheGet(options: { return cacheValue } } else { + console.debug("cache miss", redisKey) if (options.allowEmpty) { options.getValueFun().then((value) => { if (value) { diff --git a/src/middleware.ts b/src/middleware.ts index 863e244d..e509e62e 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -44,7 +44,7 @@ export default async function middleware(req: NextRequest) { return NextResponse.redirect(`https://${req.headers.get("host")}/feed`, 301) } - console.debug(`${req.method} ${req.nextUrl.pathname}${req.nextUrl.search}`) + console.debug(`${req.method} ${req.nextUrl}`) if ( pathname.startsWith("/api/") || @@ -54,7 +54,9 @@ export default async function middleware(req: NextRequest) { pathname.startsWith("/locales/") || pathname.match(/^\/(workbox|worker|fallback)-\w+\.js(\.map)?$/) || pathname === "/sw.js" || - pathname === "/sw.js.map" + pathname === "/sw.js.map" || + pathname === "/monitoring" || + pathname === "favicon.ico" ) { return NextResponse.next() }