i have a nextjs app that works fine on all the domains but i also have a domain where i use dynamic pages for sneaker product pages. The kickz.rendives.nl/products still works but when i click on a product i get the 500 Internal Server Error. I think this is because of the dynamic generated pages, i host on nginx but i don't know why it doesn't work. Locally it works just fine. Let me know if more information is needed!
I already tried doing https://geops.com/en/blog/next-nginx-routes and setting the created file in my nginx conf files (kickz.rendives.nl) with include /home/pi/PROJECT_NAME/next-routes.conf and that also didn't work. I got the same 500 internal server error.
Maybe Nginx has to be configured to handle dynamic pages but im not even sure. Help is appreciated!
UPDATE: I found out the problem isn't with nginx, i tried generating pages with an array given and that worked fine, i think the problem is with the way i make the pages (with data fetched from my mariadb database) this is my code, Im debugging now:
<h2 className="sneaker-sku ">Sku: {sizes[0]?.sku}</h2>
this is the piece of code that triggers the error.
CodePudding user response:
i don't know about nginx , but I have faced this issue before
if your website is static and you're trying to fetch data with getStaticProps or gerServerSideProps from your next API, this will cause an error. if that's the case you will need to fetch the data directly using getstarticProps and getStaticPath functions
CodePudding user response:
The problem was a line of code:
<h2 className="sneaker-sku ">Sku: {sizes[0]?.sku}</h2>
this triggered the error, i thought the problem was with nginx because of the fact it worked locally. I just debugged it and it gave me the error
TypeError: Cannot read properties of undefined (reading 'sku')
the problem was an error in my database 1 product had a wrong product name, (it didn't save the product name correctly so the 2 product names didn't match what resulted in no row returned)