Hello, I have been building this app it’s working fine on local , it breaks in production on routes like products/[id] and categories/[slug]. In console its shows
Error : Connection closed
#Error: Connection Closed
28 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
it sounds like the connection to your database was closed. Make sure you have an open DB connection to make queries
@manic mica solved?
I have removed the code where database being used and crashing has stopped, however its still crashing at some pages. I'm still working on those pages to identify whats causing this.
Thank you it was great help , can you please tell how can i fix this as im using mongodb.
can you share the full error? That would help more 👍
the last one , im not getting any error on local so its hard to find whats happening here.
https://github.com/Abhii5496/store-thing , repo if you want to take a look .
did you set up your .env variables in your production env correctly?
when does this error pop up? When you click something? Hover something? When you interact with something? ...
when i navigate to any product detail page (/products/1)
can you refresh the current page (should work, as you said) and directly navigate to any other product detail page?
no, it's up
ok its working now
whats the result of this: #1326810881891237969 message <--- click
its working fine
but when you refresh the page, wait around 15 seconds and then navigate, it shows the error?
thats right
if you remove this fetching part: https://github.com/Abhii5496/store-thing/blob/main/src/app/products/[id]/page.js#L80
And also the generateMetaData here: https://github.com/Abhii5496/store-thing/blob/main/src/app/products/[id]/page.js#L5-L74
Does the error persists?
no , after removing these two it works well.
then it looks like the api that you are using is broken (or at least serverless hosted) and then your connection is broken, because the server was shut downed. If I would be you, I would create a constants.ts file that contains some products and then use that. It's much more reliable (or of course your own database)
@manic mica solved?
you are right about the api , i'll go with contatants idea for now. Thank you very much for your help.
✅ Success!
This question has been marked as answered! If you have any other questions, feel free to create another post
Jump to answer
[Click here](#1326810881891237969 message)