Skip to content

initFirebaseRest doesn't work with edge runtime on NextJS  #8

Description

@ahsankhan26

I just came across this package and tried setting up on my repo. I am using NextJS 14 and edge runtime.
I am deploying the app on cloudflare pages so all routes have to be on edge.
Is there any workaround for this?

// app/login/page.tsx
export const runtime = 'edge';
// firebase.ts
import { initFirebaseRest } from 'firebase-admin-rest';

export const getFirebaseAdmin = async () => {
  const db = await initFirebaseRest({
    serviceAccount,
    databaseId: '(default)', 
  }).firestore();
  return db;
};

CallinggetFirebaseAdmin in a server action results in the following error.

ERROR

 [TypeError: Failed to execute 'importKey' on 'SubtleCrypto': 2nd argument is not instance of ArrayBuffer, Buffer, TypedArray, or DataView.] {
  code: 'ERR_INVALID_ARG_TYPE'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions