diff --git a/Dockerfile b/Dockerfile index 1fef778..b8fc3cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /app COPY package.json yarn.lock ./ -RUN yarn install --frozen-lockfile +RUN yarn install --frozen-lockfile sharp COPY . . COPY ./src/app/favicon.ico ./public/favicon.ico @@ -24,6 +24,8 @@ ENV NODE_ENV=production USER nextjs +RUN mkdir -p ./.next/cache + COPY --from=builder /app/public ./public COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static diff --git a/src/app/api/contact/route.ts b/src/app/api/contact/route.ts index 3ab2617..18454b6 100644 --- a/src/app/api/contact/route.ts +++ b/src/app/api/contact/route.ts @@ -44,6 +44,8 @@ export async function POST(req: NextRequest) { const cf_token = data["cf-turnstile-response"]; + console.log(`[${agent}] Verify captcha`); + if (typeof cf_token !== 'string' || !cf_token.trim()) { return NextResponse.json( { error: "Captcha Failed" }, @@ -59,6 +61,8 @@ export async function POST(req: NextRequest) { { status: 403 } ); } + + console.log(`[${agent}] Verify rate limit`); const isRateLimited = await rateLimited(agent); @@ -76,12 +80,16 @@ export async function POST(req: NextRequest) { ); } + console.log(`[${agent}] Sending email...`); + try { const email = data.anon || !data.email ? process.env.SMTP_USER : data.email; const name = trimTooLong(data.anon || !data.name ? 'Anonymous' : data.name, 20); await sendEmail(name, email, data.message); + console.log(`[${agent}] Email sended...`); + return NextResponse.json({ status: "ok" }); } catch (err) {