in next.js, we can use
getStaticProps (Static Generation): Fetch data at build time.
getStaticPaths (Static Generation): Specify dynamic routes to pre-render based >on data.
getServerSideProps (Server-side Rendering): Fetch data on each request.
to run serverside code, but in order to do that, I need to import serverside module in that script, for example, I want to import an authentication module to check the user is genuine or not in getserversideprops . (or database schemas, for example, mongoose)
Since I cannot import in a function, I have to import on the top of the file which means that anyone can see that import and see how I authenticate the user.
example:
import a from 'auth"
getserversideprops(){
if(a(req) ==true) ...
}