I get a 404 error every time I make the first request to my app homepage. It will work after a simple refresh.
Steps to reproduce:
Access https://www.zaptube.vip or curl -I https://www.zaptube.vip
curl -I https://www.zaptube.vipHTTP/2 404 accept-ranges: bytesaccess-control-allow-origin: *age: 119cache-control: public, max-age=0, must-revalidatecontent-disposition: inline; filename="404"content-type: text/html; charset=utf-8date: Wed, 08 Jan 2025 14:09:49 GMTetag: "d3503f134747dd752bf9b78f170299cb"last-modified: Wed, 08 Jan 2025 14:07:50 GMTserver: Vercelset-cookie: locale=en; Path=/strict-transport-security: max-age=63072000x-matched-path: /404x-vercel-cache: HITx-vercel-id: gru1::fjlft-1736345389516-af4b261091a4content-length: 5939In the logs I see the 404s related to requests to the /wordpress/wp-admin/setup-config.php and /wp-admin/setup-config.php endpoints (I'm not sure what are those)
I've tried some workarounds without success 😕 This is the [locale]/[slug] page:
import { redirect } from "next/navigation";import { ChannelService } from "@/app/services/channel.service";import SubscribePage from "@/app/[locale]/subscribe/[slug]/page";export default async function ChannelPage({ params,}: { params: { slug: string };}) { const channelService = new ChannelService(); let decodedSlug = decodeURIComponent(params.slug); if (decodedSlug.includes("wp-admin") || decodedSlug.includes("setup-config.php")) { console.warn(`[ChannelPage] Invalid slug: ${decodedSlug}`); return redirect("/"); } // all slugs should start with @ in the db, we will allow the user to not include it in the url if (!decodedSlug.startsWith("@")) { decodedSlug = `@${decodedSlug}`; } const channel = await channelService.getChannel({ slug: decodedSlug }, {}); if (!channel) { console.warn(`[ChannelPage] Channel not found: ${decodedSlug}`); return redirect("/"); } if (channel?.defaultLocale) { redirect(`/${channel.defaultLocale}/subscribe/${decodedSlug}`); } return <SubscribePage params={{ slug: decodedSlug }} />;}This is how my middleware is configured:
import createMiddleware from "next-intl/middleware";import { NextRequest, NextResponse } from "next/server";import { withAuth } from "next-auth/middleware";import { locales, defaultLocale } from "@/app/i18n/settings";const intlMiddleware = createMiddleware({ locales, defaultLocale, localePrefix: "never", // Prevent locales in the URL});const authMiddleware = withAuth( function middleware(req) { if ( req.nextUrl.pathname.startsWith("/admin") && req.nextauth.token === null ) { return NextResponse.redirect( new URL(`/login?callbackUrl=${encodeURIComponent(req.url)}`, req.url) ); } return NextResponse.next(); // Proceed if authenticated }, { callbacks: { authorized: ({ token }) => !!token, }, });