Merge branch 'main' into dev

This commit is contained in:
DIYgod 2023-08-01 15:58:51 +01:00
commit 16b4c56eee
No known key found for this signature in database
5 changed files with 38 additions and 3 deletions

View File

@ -4,6 +4,7 @@ module.exports = {
instances: 2,
name: "xlog",
script: "./server.js",
max_memory_restart: "4G",
},
],
}

View File

@ -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,
},
]
},
}),
),
{

View File

@ -37,6 +37,7 @@ export const GET = async (req: NextRequest) => {
type: "post",
visibility: PageVisibilityEnum.Published,
limit: 1000,
skipExpansion: true,
},
queryClient,
)

View File

@ -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) {

View File

@ -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()
}