Skip to content

Commit

Permalink
fix: restores getStaticProps functionality (#4096)
Browse files Browse the repository at this point in the history
  • Loading branch information
YazeedLoonat authored May 21, 2024
1 parent d5ab5cb commit a324a17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions sites/public/src/lib/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,24 @@ export async function fetchClosedListings(req: any) {
let jurisdiction: Jurisdiction | null = null

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function fetchJurisdictionByName(req: any) {
export async function fetchJurisdictionByName(req?: any) {
try {
if (jurisdiction) {
return jurisdiction
}

const jurisdictionName = process.env.jurisdictionName

const headers = {
passkey: process.env.API_PASS_KEY,
}
if (req) {
headers["x-forwarded-for"] = req.headers["x-forwarded-for"] ?? req.socket.remoteAddress
}
const jurisdictionRes = await axios.get(
`${process.env.backendApiBase}/jurisdictions/byName/${jurisdictionName}`,
{
headers: {
passkey: process.env.API_PASS_KEY,
"x-forwarded-for": req.headers["x-forwarded-for"] ?? req.socket.remoteAddress,
},
headers,
}
)
jurisdiction = jurisdictionRes?.data
Expand Down
4 changes: 2 additions & 2 deletions sites/public/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export default function Home(props: IndexProps) {
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function getStaticProps(context: { req: any }) {
const jurisdiction = await fetchJurisdictionByName(context.req)
export async function getStaticProps() {
const jurisdiction = await fetchJurisdictionByName()

return {
props: { jurisdiction },
Expand Down

0 comments on commit a324a17

Please sign in to comment.