update redirection logic for invites
This commit is contained in:
		
							parent
							
								
									f2589efc94
								
							
						
					
					
						commit
						a764837776
					
				@ -111,7 +111,7 @@ export function getGetServerSideProps (
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (error || !data || (notFound && notFound(data, vars, me))) {
 | 
					      if (error || !data || (notFound && notFound(data, vars, me))) {
 | 
				
			||||||
        res.writeHead(301, {
 | 
					        res.writeHead(302, {
 | 
				
			||||||
          Location: '/404'
 | 
					          Location: '/404'
 | 
				
			||||||
        }).end()
 | 
					        }).end()
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -21,7 +21,7 @@ export default function Invite ({ invite, active }) {
 | 
				
			|||||||
      <CopyInput
 | 
					      <CopyInput
 | 
				
			||||||
        groupClassName='mb-1'
 | 
					        groupClassName='mb-1'
 | 
				
			||||||
        size='sm' type='text'
 | 
					        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}>
 | 
					      <div className={styles.other}>
 | 
				
			||||||
        <span>{invite.gift} sat gift</span>
 | 
					        <span>{invite.gift} sat gift</span>
 | 
				
			||||||
 | 
				
			|||||||
@ -26,9 +26,10 @@ export async function getServerSideProps ({ req, res, query: { id, error = null
 | 
				
			|||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!data?.invite) {
 | 
					  if (!data?.invite) {
 | 
				
			||||||
    res.writeHead(301, {
 | 
					    res.writeHead(302, {
 | 
				
			||||||
      Location: '/404'
 | 
					      Location: '/404'
 | 
				
			||||||
    }).end()
 | 
					    }).end()
 | 
				
			||||||
 | 
					    return { props: {} }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (session && res) {
 | 
					  if (session && res) {
 | 
				
			||||||
@ -43,12 +44,10 @@ export async function getServerSideProps ({ req, res, query: { id, error = null
 | 
				
			|||||||
      console.log(e)
 | 
					      console.log(e)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    res.writeHead(302, {
 | 
				
			||||||
      redirect: {
 | 
					      Location: '/'
 | 
				
			||||||
        destination: '/',
 | 
					    }).end()
 | 
				
			||||||
        permanent: false
 | 
					    return { props: {} }
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user