update redirection logic for invites

This commit is contained in:
keyan 2024-04-02 19:51:30 -05:00
parent f2589efc94
commit a764837776
3 changed files with 8 additions and 9 deletions

View File

@ -111,7 +111,7 @@ export function getGetServerSideProps (
}
if (error || !data || (notFound && notFound(data, vars, me))) {
res.writeHead(301, {
res.writeHead(302, {
Location: '/404'
}).end()
}

View File

@ -21,7 +21,7 @@ export default function Invite ({ invite, active }) {
<CopyInput
groupClassName='mb-1'
size='sm' type='text'
placeholder={`https://stacker.news/invites/${invite.id}`} readOnly noForm
placeholder={`${process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://stacker.news'}/invites/${invite.id}`} readOnly noForm
/>
<div className={styles.other}>
<span>{invite.gift} sat gift</span>

View File

@ -26,9 +26,10 @@ export async function getServerSideProps ({ req, res, query: { id, error = null
})
if (!data?.invite) {
res.writeHead(301, {
res.writeHead(302, {
Location: '/404'
}).end()
return { props: {} }
}
if (session && res) {
@ -43,12 +44,10 @@ export async function getServerSideProps ({ req, res, query: { id, error = null
console.log(e)
}
return {
redirect: {
destination: '/',
permanent: false
}
}
res.writeHead(302, {
Location: '/'
}).end()
return { props: {} }
}
return {