Next.js Discord

Discord Forum

Dynamic server usage: Page couldn't be rendered statically because it used `request.cookies`

Unanswered
Minskin posted this in #help-forum
Open in Discord
MinskinOP
Error fetching companies: ex [Error]: Dynamic server usage: Page couldn't be rendered statically because it used request.cookies. See more info here: https://nextjs.org/docs/messages/dynamic-server-error

I got this error when I want to deploy. I have layout, page and page component. Want to use my prisma server action in this page component, but I get this error. I didn't use any cookies or headers action in my layout, page and page component. How can I solve this ?

that's my component where I get error when calling server action :

import React from "react";
import { Button } from "../ui/button";
import { Heart, MapPin, MoreHorizontal } from "lucide-react";
import { getVacanciesData } from "@/lib/actions/vacancies";
import Image from "next/image";
import { Badge } from "../ui/badge";
import NotFound from "../shared/NotFound";

const FeaturedVacancies = async () => {
  const vacanciesData = await getVacanciesData({
    isPremium: true,
    take: 3,
  });
  return (
    <div className="flex flex-col gap-3 md:gap-7">
    </div>
  );
};

export default FeaturedVacancies;


my server action
"use server";
import { startOfDay, startOfMonth, startOfWeek } from "date-fns";
import db from "../db";

export const getVacanciesData = async (filter = {}) => {
};


This server action works in my other pages and components without any problem.

0 Replies