Replies: 1 comment
-
What version of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As the title suggests the AuthUser is server side does not work in production only local: `import { init } from "next-firebase-auth"
const initAuth = () => {
init({
authPageURL: "/",
appPageURL: "/",
loginAPIEndpoint: "/api/login",
logoutAPIEndpoint: "/api/logout",
onLoginRequestError: (err) => {
console.error(err)
},
onLogoutRequestError: (err) => {
console.error(err)
},
// firebaseAuthEmulatorHost: "localhost:9099",
firebaseAdminInitConfig: {
credential: {
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
// The private key must not be accessible on the client side.
privateKey: process.env.FIREBASE_PRIVATE_KEY
? JSON.parse(process.env.FIREBASE_PRIVATE_KEY)
: undefined,
},
databaseURL: process.env.NEXT_PUBLIC_DATABASE_URL,
},
// Use application default credentials (takes precedence over firebaseAdminInitConfig if set)
// useFirebaseAdminDefaultCredential: true,
firebaseClientInitConfig: {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
},
cookies: {
name: "[REDACTED]", // required
// Keys are required unless you set
signed
tofalse
.// The keys cannot be accessible on the client side.
keys: [
process.env.COOKIE_SECRET_CURRENT,
process.env.COOKIE_SECRET_PREVIOUS,
],
httpOnly: true,
maxAge: 12 * 60 * 60 * 24 * 1000, // twelve days
overwrite: true,
path: "/",
sameSite: "lax",
secure: process.env.NODE_ENV === "production", // set this to false in local (non-HTTPS) development
signed: true,
},
onVerifyTokenError: (err) => {
console.error(err)
},
onTokenRefreshError: (err) => {
console.error(err)
},
})
}
export default initAuth
. I get these logs:
DEFAULT 2023-03-29T08:14:58.969232Z next-firebase-auth: [setAuthCookies] Attempting to set auth cookies.DEFAULT 2023-03-29T08:14:58.998232Z next-firebase-auth: [setAuthCookies] Getting a refresh token from the ID token.
DEFAULT 2023-03-29T08:14:59.086438Z next-firebase-auth: [setAuthCookies] Failed to verify the ID token. Cannot authenticate the user or get a refresh token.
DEFAULT 2023-03-29T08:14:59.088333Z next-firebase-auth: [setAuthCookies] Set auth cookies. The user is not authenticated.
`
Beta Was this translation helpful? Give feedback.
All reactions