try to fix runtime error and add runtime logs
This commit is contained in:
parent
598fbf9d4a
commit
90f6e840f3
@ -6,7 +6,7 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY package.json yarn.lock ./
|
COPY package.json yarn.lock ./
|
||||||
|
|
||||||
RUN yarn install --frozen-lockfile
|
RUN yarn install --frozen-lockfile sharp
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
COPY ./src/app/favicon.ico ./public/favicon.ico
|
COPY ./src/app/favicon.ico ./public/favicon.ico
|
||||||
@ -24,6 +24,8 @@ ENV NODE_ENV=production
|
|||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
|
RUN mkdir -p ./.next/cache
|
||||||
|
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
|
|||||||
@ -44,6 +44,8 @@ export async function POST(req: NextRequest) {
|
|||||||
|
|
||||||
const cf_token = data["cf-turnstile-response"];
|
const cf_token = data["cf-turnstile-response"];
|
||||||
|
|
||||||
|
console.log(`[${agent}] Verify captcha`);
|
||||||
|
|
||||||
if (typeof cf_token !== 'string' || !cf_token.trim()) {
|
if (typeof cf_token !== 'string' || !cf_token.trim()) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: "Captcha Failed" },
|
{ error: "Captcha Failed" },
|
||||||
@ -60,6 +62,8 @@ export async function POST(req: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[${agent}] Verify rate limit`);
|
||||||
|
|
||||||
const isRateLimited = await rateLimited(agent);
|
const isRateLimited = await rateLimited(agent);
|
||||||
|
|
||||||
if (isRateLimited) {
|
if (isRateLimited) {
|
||||||
@ -76,12 +80,16 @@ export async function POST(req: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[${agent}] Sending email...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const email = data.anon || !data.email ? process.env.SMTP_USER : data.email;
|
const email = data.anon || !data.email ? process.env.SMTP_USER : data.email;
|
||||||
const name = trimTooLong(data.anon || !data.name ? 'Anonymous' : data.name, 20);
|
const name = trimTooLong(data.anon || !data.name ? 'Anonymous' : data.name, 20);
|
||||||
|
|
||||||
await sendEmail(name, email, data.message);
|
await sendEmail(name, email, data.message);
|
||||||
|
|
||||||
|
console.log(`[${agent}] Email sended...`);
|
||||||
|
|
||||||
return NextResponse.json({ status: "ok" });
|
return NextResponse.json({ status: "ok" });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user