Changing settings so it works when redis is down.

This commit is contained in:
Dustin Rouillard
2022-05-11 17:09:21 -06:00
parent 0551bff539
commit 6e54731b62
2 changed files with 9 additions and 2 deletions

View File

@@ -98,7 +98,10 @@ export default function Home({ userCount }: { userCount: number }) {
}
export async function getServerSideProps(ctx: any) {
let userCount = await axios.get("https://lanyard.cnrad.dev/api/getUserCount").then(res => res.data.count);
let userCount = await axios
.get("https://lanyard.cnrad.dev/api/getUserCount", { timeout: 1000 })
.then(res => res.data.count)
.catch(() => 0);
return {
props: { userCount },

View File

@@ -1,5 +1,9 @@
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL);
const redis = new Redis(process.env.REDIS_URL, {
connectTimeout: 1000,
lazyConnect: false,
maxRetriesPerRequest: 1,
});
export default redis;