0

I am using next-connect to chain middleware inside the getServerSideProps and have the same set of middleware in the next JS API. I am calling the same using axios on client side.

How do I write a common logic in the middleware to redirect to another page.

c_Jane
  • 1
  • Is there anything you've tried and didn't work ? – IGnyte Oct 12 '22 at 13:08
  • I tried 1. res.writeHead(302, { location: '/Login' }) works with SSE but not axios. 2. res.status(403).json({ status: 'Non-authenticated user.' }) and check for status code =403 on axios. But this does not work with SSE. I get an error like res.status is not a function – c_Jane Oct 13 '22 at 04:57

0 Answers0