在 Amplify 上构建 Next.js 应用程序时包含压缩的安全连接文件

问题描述 投票:0回答:1

在 node.js 中有一个用于连接到 Datastax Astra-DB Cassandra 数据库的驱动程序,称为“cassandra-driver”。对于传统连接,它使用名为 secure-connect-{DB-Name}.zip 的连接密钥文件,语法如下:

const client = new Client({
  cloud: {
    secureConnectBundle: 'Address of the zipped file'
  },
  credentials: {
    username: 'This is client_id',
    password: 'This is client_secret',
  },
});

在本地,语法运行良好,但当我将其部署在 AWS Amplify 上时,由于文件未放入 Next.js 包中,将引发文件未找到错误。现在的问题是:有没有办法将文件保存在 Next.js 包中的 Amplify 本身,而不是将其上传到外部存储(如 S3,一种愚蠢的方式!)来访问?

next.js datastax cassandra-driver
1个回答
0
投票

我遇到了同样的问题,在我的例子中是将它部署到 Vercel。问题可以这样解决,

  1. 将您的 Secure Bundle Zip 放在项目的根目录下。
  2. 现在像这样修改你的代码:

const client = new Client({
  cloud: {
    secureConnectBundle: path.join(
          process.cwd(),
          "filename.zip"
        )
  },
  credentials: {
    username: 'This is client_id',
    password: 'This is client_secret',
  },
});

如果这对你有用,请告诉我

© www.soinside.com 2019 - 2024. All rights reserved.