Next.js Discord

Discord Forum

website wont load after initializing firebase-admin

Answered
Pachon Navarro posted this in #help-forum
Open in Discord
Pachon NavarroOP
 ⨯ ./node_modules/farmhash-modern/bin/bundler/farmhash_modern_bg.wasm
Module parse failed: Unexpected character '' (1:0)
The module seem to be a WebAssembly module, but module is not flagged as WebAssembly module for webpack.
BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature.
You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated).
For files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: "webassembly/async"').
(Source code omitted for this binary file)


code:

import * as admin from 'firebase-admin';
import { getApps, getApp, initializeApp } from "firebase/app"
import { getAuth, signInWithEmailAndPassword, signOut } from "firebase/auth"

const firebaseConfig = {
  ... (hidden)
}

const adminApp = admin.initializeApp(firebaseConfig)

const app = initializeApp(firebaseConfig)
const auth = getAuth(app)

const signInUser = (
  email: string, 
  password: string,
  callback: (err?: any) => void
) => {
  signInWithEmailAndPassword(auth, email, password).then((credentials) => {
    if (credentials) {
      console.log(credentials.user)
      callback()
    }
  }).catch((err) => {
    callback(err)
  })
}

const logOutUser = (
  callback: (err?: any) => void
) => {
  signOut(auth).then(() => {
    callback()
  }).catch((err) => {
    callback(err)
  })
}

export { adminApp, app, auth, signInUser, logOutUser }


this issue doesnt make sense nor does nextjs/error handler provides a humanly understandable response

88 Replies

@Pachon Navarro ⨯ ./node_modules/farmhash-modern/bin/bundler/farmhash_modern_bg.wasm Module parse failed: Unexpected character '' (1:0) The module seem to be a WebAssembly module, but module is not flagged as WebAssembly module for webpack. BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature. You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated). For files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: "webassembly/async"'). (Source code omitted for this binary file) code: ts import * as admin from 'firebase-admin'; import { getApps, getApp, initializeApp } from "firebase/app" import { getAuth, signInWithEmailAndPassword, signOut } from "firebase/auth" const firebaseConfig = { ... (hidden) } const adminApp = admin.initializeApp(firebaseConfig) const app = initializeApp(firebaseConfig) const auth = getAuth(app) const signInUser = ( email: string, password: string, callback: (err?: any) => void ) => { signInWithEmailAndPassword(auth, email, password).then((credentials) => { if (credentials) { console.log(credentials.user) callback() } }).catch((err) => { callback(err) }) } const logOutUser = ( callback: (err?: any) => void ) => { signOut(auth).then(() => { callback() }).catch((err) => { callback(err) }) } export { adminApp, app, auth, signInUser, logOutUser } this issue doesnt make sense nor does nextjs/error handler provides a humanly understandable response
it does provide it a good error log
Pachon NavarroOP
not really
just from firebase-admin
are u sure u followed the documentation for firebase correctly
u are importing *
from firebase admin
Pachon NavarroOP
one second
@gin u are importing *
that could cause it to import some weird wasm module
that is not supported by nextjs
Pachon NavarroOP
even without it
it imports a wasm module
i guess i need to use it in a server env
in this case
@Pachon Navarro i guess i need to use it in a server env
no wasm runs on the client
Pachon NavarroOP
on the sdk it says its for a server env
i was using it on the client :facepalm:
ah i see
so u fixed it?
Pachon NavarroOP
let me just make a server rq
and test it out
give me 8 minutes
bruh
is there a reason u use firebase
Pachon NavarroOP
authentication
Answer
Pachon NavarroOP
why supabase?
cause its supported by nextjs and is opensource
and is better than firebase
has everything firebase has
and is free
Pachon NavarroOP
is there a user limit?
no, u can selfhost
Pachon NavarroOP
no fucking way really?
yeah
Pachon NavarroOP
let me just test it out
one second
does it also have user token/cookie stuff?
@Pachon Navarro does it also have user token/cookie stuff?
are u searching for only a auth?
use this
Pachon NavarroOP
yes
Pachon NavarroOP
oh nextauth
yeah i recommend using that
cause supabase is more like a whole ass backend system with db, live features, auth and permissions management
would be overkill
better to manage your own db
Pachon NavarroOP
i have my own db
postgres
but for users id js use supabase
yeah u can
authjs should have a supabase adapter
Pachon NavarroOP
how can i use it for email + password auth?
auth.js
i always use nextauth
but for this type idk much
check this
Pachon NavarroOP
okay
+ should i remove the other next-auth
@Pachon Navarro + should i remove the other next-auth
yeah u should use the up to date one
Pachon NavarroOP
so in auth.ts how can i get supabase
for authentication email + password
nvm
Pachon NavarroOP
@gin also would i need to do it this way
u can directly return user
otherwise return null
Pachon NavarroOP
so like this?
+ in order to get the session is it through here?
@Pachon Navarro so like this?
yeah
Pachon NavarroOP
okay
@Pachon Navarro + in order to get the session is it through here?
yeah u call this in your server components
Pachon NavarroOP
ill js do a test
for signing in it is like this right?
i think so
follow the docs
Pachon NavarroOP
okay i am good
time to test
wait
@Pachon Navarro use this
Pachon NavarroOP
i am using supabase for auth
yeah i recommend that for u but i didnt know u only want a auth
Pachon NavarroOP