I try make an app like instagram. Using nextjs 15 app router. For file storage i'm using cloudinary. Everything is fine in development but in production error occurs.
When i try to perform like post this error happens.
TypeError: f.v2.config is not a function
at 64314 (.next/server/chunks/207.js:1:28341)
at t (.next/server/webpack-runtime.js:1:143)
at 39087 (.next/server/chunks/50.js:1:756)
at Object.t [as require] (.next/server/webpack-runtime.js:1:143) {
digest: '1690469834'
--- action file
"use server";
import { z } from "zod";
import { fetchFeedPosts } from "../drizzle/queries/posts/fetchFeedPosts";
import { fetchPostLikes } from "../drizzle/queries/posts/fetchPostLikes";
import { fetchUserPosts } from "../drizzle/queries/posts/fetchUserPosts";
import PostService from "../drizzle/services/PostService";
import { authActionClient } from "../safeAction";
import { revalidateTag } from "next/cache";
import { POST } from "../cacheKeys";
export const likePost = authActionClient
.schema(
z.object({
postId: z.string(),
}),
)
.bindArgsSchemas<[pathname: z.ZodString]>([z.string()])
.action(async ({ ctx: { session }, parsedInput: { postId } }) => {
const { id: userId } = session.user;
const postService = new PostService();
try {
const likeRows = await postService.findLike({ postId, userId });
let message = "";
if (likeRows.length === 0) {
await postService.like({ postId, userId });
message = "like";
} else {
await postService.dislike({ postId, userId });
message = "dislike";
}
revalidateTag(POST.detail);
revalidateTag(POST.homePosts);
revalidateTag(POST.likes);
return message;
} catch (err) {
console.log(err);
throw err;
}
});
---- cludinary setup file
import { v2 as cloudinary } from "cloudinary";
cloudinary.config({
cloud_name: process.env.CLOUDINARY_NAME,
api_key: process.env.CLOUDINARY_KEY,
api_secret: process.env.CLOUDINARY_SECRET,
});
export async function removeFileFromCloudinary(publicId: string) {
await cloudinary.uploader.destroy(publicId);
}
export async function uploadFileToCloudinary(file: File) {
const arrayBuffer = await file.arrayBuffer();
const buffer = new Uint8Array(arrayBuffer);
const data = await new Promise((resolve, reject) => {
cloudinary.uploader
.upload_stream(
{
folder: "nextgram",
},
(err: any, result: any) => {
if (err) {
reject(err);
return;
}
resolve(result);
},
)
.end(buffer);
});
return data;
}
I do realize that i have nothing todo with file upload in this context. But that error keep occur which cause my likePost action failed.
I've tried reinstall the cloudinary package. I've adjusted next.config.mjs
webpack: (config, { isServer }) => {
if (!isServer) {
config.optimization.minimize = false; // Disable minification on the client
}
return config;
},