From 7d248cf91bd6901a0c9a08511b3ebef4e7d3355e Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 25 Dec 2022 16:03:32 -0800 Subject: [PATCH] Remove headers --- pages/p/[party].tsx | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/pages/p/[party].tsx b/pages/p/[party].tsx index 0496d603..806637bc 100644 --- a/pages/p/[party].tsx +++ b/pages/p/[party].tsx @@ -7,6 +7,7 @@ import Party from '~components/Party' import { appState } from '~utils/appState' import { groupWeaponKeys } from '~utils/groupWeaponKeys' import organizeRaids from '~utils/organizeRaids' +import setUserToken from '~utils/setUserToken' import api from '~utils/api' import type { NextApiRequest, NextApiResponse } from 'next' @@ -48,38 +49,35 @@ export const getServerSidePaths = async () => { // prettier-ignore export const getServerSideProps = async ({ req, res, locale, query }: { req: NextApiRequest, res: NextApiResponse, locale: string, query: { [index: string]: string } }) => { - // Cookies - const cookie = getCookie("account", { req, res }) - const accountData: AccountCookie = cookie - ? JSON.parse(cookie as string) - : null - - const headers = accountData - ? { headers: { Authorization: `Bearer ${accountData.token}` } } - : {} + // Set headers for server-side requests + setUserToken(req, res) let { raids, sortedRaids } = await api.endpoints.raids .getAll() .then((response) => organizeRaids(response.data)) let jobs = await api.endpoints.jobs - .getAll({ params: headers }) + .getAll() .then((response) => { return response.data }) - let jobSkills = await api.allJobSkills(headers).then((response) => response.data) + let jobSkills = await api + .allJobSkills() + .then((response) => response.data) let weaponKeys = await api.endpoints.weapon_keys .getAll() .then((response) => groupWeaponKeys(response.data)) - + let party: Party | null = null if (query.party) { - let response = await api.endpoints.parties.getOne({ id: query.party, params: headers }) + let response = await api.endpoints.parties.getOne({ + id: query.party + }) party = response.data.party } else { - console.log("No party code") + console.log('No party code') } return { @@ -90,7 +88,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex raids: raids, sortedRaids: sortedRaids, weaponKeys: weaponKeys, - ...(await serverSideTranslations(locale, ["common"])), + ...(await serverSideTranslations(locale, ['common'])), // Will be passed to the page component as props }, }