This is a Next.js project bootstrapped with create-next-app
and integrated with Milvus Node SDK.
First, initialize a Next.js project:
npx create-next-app@latest
Then, install Milvus Node SDK:
yarn add @zilliz/milvus2-sdk-node
Update next.config.js
, Server-side bundling ignores @zilliz/milvus2-sdk-node.
Fixed the issue of "Unable to load service: milvus.proto.milvus.MilvusService"
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['@zilliz/milvus2-sdk-node'],
outputFileTracingIncludes: {
// When deploying to Vercel, the following configuration is required
'/api/**/*': ['node_modules/@zilliz/milvus2-sdk-node/dist/proto/**/*'],
},
},
};
module.exports = nextConfig;
you can try this tip:
config.externals.push('@zilliz/milvus2-sdk-node');
Create a server page component in pages/index.js
. This component will interact with Milvus Node SDK to perform operations.
Create a router API in pages/api/milvus.js
. This API will handle requests from the client and interact with Milvus Node SDK.
You can now access the application at:
- Main page:
http://localhost:3000/
- Milvus API:
http://localhost:3000/api/milvus