-
Notifications
You must be signed in to change notification settings - Fork 980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
500 server error Dynamic Page Routes Next js 15 #8244
Comments
Thanks for reporting this issue! I believe the problem is with your Firebase Admin initialization. There is a tree-shaking issue. When your app is built for production, webpack is tree-shaking the Firebase Admin dependencies out of the bundle because of how you've structured your initialization. The most straightforward fix is to modify your firebaseServer.tsx file to initialize Firebase Admin at the top level of the module, i've reproduced and the code below seems to work:
Also ideally make sure you initialize the firestore passing the app instance, when using the getFirestore function.
|
@emwp @leoortizz Here is my Server Admin:
Here is my Client Admin:
When I look into the SSR next function log, I see an error of: Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services. My package.json:
|
@emwp
I get this error logged in the ssr function: Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services. |
Hey @JwillSDP, in those examples you're still caliing Calling it like this should resolve the problem:
|
I got this to work but ONLY in Production:
I have to use the conditional to make it work in development. What is that about?
I hope that the client SDK will still work in production. I need it for the tokens to the server.
Do I need to put the app in the Client? I took it out in the Server
|
Hey @JwillSDP thanks for following up. We've checked with the internal Firebase team, and a specific fix for this issue won't be pursued at the moment. I've checked locally and with a very similar codebase to yours I am able to run it both in production as well as in development locally, here is the example repository I was testing with: https://github.com/emwp/firebase-example Hope that helps! |
Hey @JwillSDP. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
<!--
DO NOT DELETEvalidate_template=true
template_path=.github/ISSUE_TEMPLATE/bug_report.md
-->
[REQUIRED] Environment info
firebase-tools: 13.31.1
Platform: Windows
[REQUIRED] Test case
I am using Next js 15
The issues is getting data from firebase into server comps on dynamic pages
I can get the slug from the URL but if I use a server action to get any data from firebase, It will show 500 Internal Server Error only in PRODUCTION
This 500 Internal Server Error is not seen in the development and firebase emulator.
I cant get firebase data into a dynamic page routes without getting a 500 error from the server in PRODUCTION
Static routes are able to get data from Firebase without the 500 Error
Using App router in NEXT JS 15
[REQUIRED] Steps to reproduce
Create Next JS app
Create dynamic page routes in app folder
use the dynamic slug as ID for a document in a collection
Create server action to get doc from collection into a server comp on dynamic page route
Pass data to client comp for display
[REQUIRED] Expected behavior
dynamic routes use the slugs as ID for a document in a collection
Server comp on dynamic page uses slug for ID to get data from server action using firebase
Data passed into client comp
Data displayed in client comp
[REQUIRED] Actual behavior
500 Internal Server Error
The text was updated successfully, but these errors were encountered: