Skip to content

Commit

Permalink
fix: disable referrer check
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Jul 10, 2024
1 parent 0f00655 commit ef01a7c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-mails-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"web": minor
---

fix: disable referrer check
29 changes: 18 additions & 11 deletions apps/web/src/pages/[studyProgram]/schedule/import/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ function ImportSchedulePage({ items }: ImportPageProps) {
}

// TODO: research security issues for importing from other 3rd party data sources
const whitelistedOrigins = ['https://esc.eng.chula.ac.th', 'http://localhost:8000']
// const whitelistedOrigins = ['https://esc.eng.chula.ac.th', 'http://localhost:8000']

export async function getServerSideProps(
context: GetServerSidePropsContext
): Promise<GetServerSidePropsResult<ImportPageProps>> {
const referer = context.req.headers.referer as string
const isFromWhitelistedOrigins = whitelistedOrigins.some((origin) => {
return typeof referer === 'string' && referer.startsWith(origin)
})
if (!isFromWhitelistedOrigins) {
return {
notFound: true,
}
}
// const referer = context.req.headers.referer as string
// const isFromWhitelistedOrigins = whitelistedOrigins.some((origin) => {
// return typeof referer === 'string' && referer.startsWith(origin)
// })
// if (!isFromWhitelistedOrigins) {
// return {
// notFound: true,
// }
// }
try {
const client = createApolloServerClient()
const q = context.query
Expand All @@ -90,13 +90,20 @@ export async function getServerSideProps(
}
})
.filter((it) => it !== null) as RawScheduleItem[]
const items = await Promise.all(rawItems.map((it) => fetchItem(client, courseGroup, it)))
console.log({ rawItems, courseGroup })
const items = await Promise.all(
rawItems.map((it) => {
console.log({ courseGroup, it })
return fetchItem(client, courseGroup, it)
})
)
return {
props: {
items,
},
}
} catch (e: unknown) {
console.log({ e })
if (isApolloError(e as Error)) {
return {
notFound: true,
Expand Down

0 comments on commit ef01a7c

Please sign in to comment.