1

Hi everyone. I am working on a page where the content of the page rarely changes(but it can be changed by the user whenever he wants) so I want to make that page to load fast and getStaticProps does this for me and on any change I can just revalidate that route, but cause thats the product page I want to save the user views on that page. I can save the user who are logged in with their IDs but for non logged in user I have to save their IP and now the problem is for the IP I cant use the staticProps and I have to use serverSideProps which is way more slower than staticProps!, what do you guys suggest I should do? (How can I have the best of both worlds?) I have searched and every answer just suggests that you have to use serverSideProps

Similar question on Stackoverflow: (but the approved ans suggests serverSideProps) Get the client IP on NextJS and use SSR

SC K
  • 141
  • 8
  • 1
    You could move the logic to retrieve the IP to an API route, then make a request to it from the client-side to retrieve the IP. – juliomalves Aug 22 '22 at 22:04
  • Tnx @juliomalves I am doing that right now, but it kinda seems hacky, I think middleware should simply just give the req obj that we can get in an api route. – SC K Sep 05 '22 at 01:12

0 Answers0