前端winter、楊村長(zhǎng)、然叔Node進(jìn)階實(shí)踐
ontext,類型為 NextPageContext
context.req / context.res 可以獲取請(qǐng)求和響應(yīng)
一般只需要用到 context.req
栗子??:
export const getServerSideProps: GetServerSideProps = async (context) => {
?const ua = context.req.headers["user-agent"]
?return {
? ?props: {
? ? ?ua,
? ?}
?}}
必須按照這個(gè)格式,不能變(命名和返回值{ props: {...} })
標(biāo)簽: