From ef01a7c2a91f9ee3293653e2fff67e9e27072801 Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Wed, 10 Jul 2024 23:55:44 +0700 Subject: [PATCH] fix: disable referrer check --- .changeset/real-mails-beg.md | 5 ++++ .../[studyProgram]/schedule/import/index.tsx | 29 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 .changeset/real-mails-beg.md diff --git a/.changeset/real-mails-beg.md b/.changeset/real-mails-beg.md new file mode 100644 index 000000000..cb4f085a2 --- /dev/null +++ b/.changeset/real-mails-beg.md @@ -0,0 +1,5 @@ +--- +"web": minor +--- + +fix: disable referrer check diff --git a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx index d4060d625..6663ccd57 100644 --- a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx +++ b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx @@ -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> { - 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 @@ -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,