Next.js 15 + app router + postrgesql + nginx (problem in request to DB during building)
Unanswered
Polar bear posted this in #help-forum
Polar bearOP
Hi guys! I have a problem with Next.js 15 (with Next.js 14 - it worked).
Example app page
what's going on - When Docker builds the image and RUN npm run build - Next.js 15 generate static pages (why, why she it do? page contain db requests!) and finishing with error - can't connect to DB. Next.js 14 - it is work fine. What should I do now? 😩
Docker-compose.yml
version: "3.8"
networks:
app_network:
driver: bridge
name: vkusno_network
services:
postgres:
image: postgres:14-alpine
ports:
- 5432:5432
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=vkusnouser
- POSTGRES_DB=vkusno
container_name: postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready -U vkusnouser -d vkusno"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- app_network
nextjs:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
networks:
- app_network
volumes:
postgres_data:
driver: local
Example app page
import { GetUsers } from "@/actions/users";
export default async function UsersPage() {
const users = await GetUsers();
return (
<div className="flex flex-col space-y-6">
<div className="flex items-center justify-between lg:px-[60px]">
<h1 className="font_play text-2xl font-semibold">Пользователи</h1>
<CreateUserBtn />
</div>
<div className="flex flex-col">
{users.map((user) => (
<div key={user.id} className="lg:px-[60px] hover:bg-[#F1F4F9]">
....
</div>
))}
</div>
</div>
);
}
what's going on - When Docker builds the image and RUN npm run build - Next.js 15 generate static pages (why, why she it do? page contain db requests!) and finishing with error - can't connect to DB. Next.js 14 - it is work fine. What should I do now? 😩