Remove headers
This commit is contained in:
parent
cd2836a1cb
commit
7d248cf91b
1 changed files with 13 additions and 15 deletions
|
|
@ -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,27 +49,22 @@ 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()
|
||||||
|
|
@ -76,10 +72,12 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
||||||
|
|
||||||
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
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue