简体   繁体   English

NextJs SSR 构建在 Amplify 上部署失败

[英]NextJs SSR build fails deployment on Amplify

I want to host and deploy a Next.js build that uses SSR pages on Amplify.我想在 Amplify 上托管和部署一个使用 SSR 页面的 Next.js 构建。 The app builds in the local environment however, when I try to deploy it from the AWS/Amplify website by simply pushing updated file to Github repo.但是,当我尝试通过简单地将更新的文件推送到 Github 存储库来从 AWS/Amplify 网站部署它时,该应用程序构建在本地环境中。 It does points out that it's a webpack error.它确实指出这是一个 webpack 错误。 PS.附注。 I'm using Firebase Firestore and Auth on the serverside and haven't set up anything for that to work with Amplify.我在服务器端使用 Firebase Firestore 和 Auth,并没有设置任何与 Amplify 一起使用的东西。 错误指出令牌

For those that come across build fails from deploying NextJs SSR apps with Firebase backend (Firestore,Auth,Analytics).对于那些使用 Firebase 后端(Firestore、Auth、Analytics)部署 NextJs SSR 应用程序时遇到构建失败的人。 I removed the split function error and I received another error about private key not being read correctly.我删除了拆分函数错误,并且收到了另一个关于私钥未正确读取的错误。 I just added .replace(/\\\\n/g, '\\n') to the private key field in the Firebase Admin initialization file.我刚刚将.replace(/\\\\n/g, '\\n')到 Firebase 管理初始化文件中的私钥字段。

if (!privateKey || !clientEmail || !projectId) {
    console.log(
      `Failed to load Firebase credentials. Follow the instructions in the README to set your Firebase credentials inside environment variables.`
    );
  }
  
  if (!firebaseAdmin.apps.length) {
    firebaseAdmin.initializeApp({
      credential: firebaseAdmin.credential.cert({
        privateKey: privateKey.replace(/\\n/g, '\n'),
        clientEmail,
        projectId,
      }),
    //   databaseURL: `https://${projectId}.firebaseio.com`,
    });
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM