Remove headers

This commit is contained in:
Justin Edmund 2022-12-25 16:03:32 -08:00
parent cd2836a1cb
commit 7d248cf91b

View file

@ -7,6 +7,7 @@ import Party from '~components/Party'
import { appState } from '~utils/appState' import { appState } from '~utils/appState'
import { groupWeaponKeys } from '~utils/groupWeaponKeys' import { groupWeaponKeys } from '~utils/groupWeaponKeys'
import organizeRaids from '~utils/organizeRaids' import organizeRaids from '~utils/organizeRaids'
import setUserToken from '~utils/setUserToken'
import api from '~utils/api' import api from '~utils/api'
import type { NextApiRequest, NextApiResponse } from 'next' import type { NextApiRequest, NextApiResponse } from 'next'
@ -48,38 +49,35 @@ export const getServerSidePaths = async () => {
// prettier-ignore // prettier-ignore
export const getServerSideProps = async ({ req, res, locale, query }: { req: NextApiRequest, res: NextApiResponse, locale: string, query: { [index: string]: string } }) => { export const getServerSideProps = async ({ req, res, locale, query }: { req: NextApiRequest, res: NextApiResponse, locale: string, query: { [index: string]: string } }) => {
// Cookies // Set headers for server-side requests
const cookie = getCookie("account", { req, res }) setUserToken(req, res)
const accountData: AccountCookie = cookie
? JSON.parse(cookie as string)
: null
const headers = accountData
? { headers: { Authorization: `Bearer ${accountData.token}` } }
: {}
let { raids, sortedRaids } = await api.endpoints.raids let { raids, sortedRaids } = await api.endpoints.raids
.getAll() .getAll()
.then((response) => organizeRaids(response.data)) .then((response) => organizeRaids(response.data))
let jobs = await api.endpoints.jobs let jobs = await api.endpoints.jobs
.getAll({ params: headers }) .getAll()
.then((response) => { .then((response) => {
return response.data 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 let weaponKeys = await api.endpoints.weapon_keys
.getAll() .getAll()
.then((response) => groupWeaponKeys(response.data)) .then((response) => groupWeaponKeys(response.data))
let party: Party | null = null let party: Party | null = null
if (query.party) { 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 party = response.data.party
} else { } else {
console.log("No party code") console.log('No party code')
} }
return { return {
@ -90,7 +88,7 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
raids: raids, raids: raids,
sortedRaids: sortedRaids, sortedRaids: sortedRaids,
weaponKeys: weaponKeys, weaponKeys: weaponKeys,
...(await serverSideTranslations(locale, ["common"])), ...(await serverSideTranslations(locale, ['common'])),
// Will be passed to the page component as props // Will be passed to the page component as props
}, },
} }