-
Notifications
You must be signed in to change notification settings - Fork 892
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
[FirebaseServerApp] Failed to initialize in Next.JS Edge Runtime #8299
[FirebaseServerApp] Failed to initialize in Next.JS Edge Runtime #8299
Comments
Same issue, so I followed this |
Problem is that solution does not solve this issue, nor allow you to use J |
That solution is from nearly a year before |
#1773 is the source of the issue. it was initially applied to detect Firebase Lite in browsers, it seems, and was changed to include web workers as well. But that is invalid as it's not explicitly checking if it's a WebWorker. |
Then the question becomes how do you differentiate a Web Worker from a Cloudflare Worker (what Vercel Edge uses too). Possible fix: https://community.cloudflare.com/t/how-to-detect-the-cloudflare-worker-runtime/293715/2 Of course you would need to check for other potential environments like Fastify... and maybe Deno and Bun runtimes as well to be complete... J FWI there maybe more issues other than isBrowser, but we can't check for them until this is fixed. |
We could use |
update browser detection logic: detect either window or web worker (WorkerGlobalScope). fixes firebase#8299 firebase#8284
update browser detection logic: detect either window or web worker (WorkerGlobalScope). fixes firebase#8299 firebase#8284
update browser detection logic: detect either window or web worker (WorkerGlobalScope). fixes firebase#8299 firebase#8284
another issue |
… is unsupported by runtime FinalizationRegistry is required only if releaseOnDeref is provided in config; guard clause in initializeServerApp throws error if it's unsupported. firebase#8299
…upported FinalizationRegistry is required only if releaseOnDeref is provided in config; guard clause in initializeServerApp throws error if it's unsupported. firebase#8299
Same problem here, any updates? |
update browser detection logic: detect either window or web worker (WorkerGlobalScope). fixes firebase#8299 firebase#8284
@DellaBitta - Is there a @next or a way to test this before release? |
@jdgamble555 you can use |
Operating System
N/A
Browser Version
N/A
Firebase SDK Version
10.12.2
Firebase SDK Product:
Auth
Describe your project's tooling
Next.JS
Describe the problem
I cannot use
initializeServerApp
in Next.JS middleware (Edge runtime) to secure the server at middleware as intended.However, just commenting out
isBrowser()
guard clause makes it run as intended.I understand why it fails (Edge runtime is essentially the same as Browser runtime) and why the guard clause is there, but implementing security in Next.JS middleware is a life-saver in code complexity.
Third-party libraries like
next-firebase-auth-edge
require the use of service account credentials which is not ideal especially sinceFirebaseServerApp
does what is required without the same.Steps and code to reproduce issue
Authorization
header as in https://firebase.google.com/codelabs/firebase-nextjsinitializeServerApp
andAuth
The text was updated successfully, but these errors were encountered: