Search params in url throws page not found. Nextjs 14 app dir
Unanswered
Romanian Mioritic Shepherd Dog posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Romanian Mioritic Shepherd DogOP
Hello, I am trying to have a page with params in the url, but it keeps throwing a page not found when there are params present. When there are not params present, the page loads fine with the content.
This is what I have in my page.tsx file:
Would appreciate any help thank you!
This is what I have in my page.tsx file:
const Page = ({
searchParams,
}: {
searchParams: { plan: Plan; state: string; code: string };
}) => {
console.log("MainAgencyPage searchParams: ", searchParams);
return (
<div className="flex justify-center items-center mt-4">
<div className="max-w-[850px] border-[1px] p-4 rounded-xl">
<h1 className="text-4xl"> Create An Agency</h1>
</div>
</div>
);
};
export default Page;
Would appreciate any help thank you!
![Image](https://cdn.discordapp.com/attachments/1208175136218423396/1208175136478462002/Screenshot_2024-02-16_171232.png?ex=65e253c7&is=65cfdec7&hm=0e0143351d32cef182e9d4f9da27b800465c32b72f35da6814177644a1c4e9b4&)
5 Replies
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
What does the layout look like?
![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Romanian Mioritic Shepherd DogOP
This is my layout for my (main) group, which the agency page is in:
And this is my root layout:
import { auth } from "@/auth";
import { SessionProvider } from "next-auth/react";
import React from "react";
export default async function layout({
children,
}: Readonly<{ children: React.ReactNode }>) {
const session = await auth();
return <SessionProvider session={session}>{children}</SessionProvider>;
}
And this is my root layout:
export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en" suppressHydrationWarning>
<body className={font.className}>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<ClientLayout>{children}</ClientLayout>
<Toaster />
<SonnarToaster position="top-center" richColors />
</ThemeProvider>
</body>
</html>
);
}
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
Ok, you're using
There must be something happening there that's causing 404 responses on pages that exist.
Your
next-auth
, so you must have a middleware file that manages redirections.There must be something happening there that's causing 404 responses on pages that exist.
Your
page.tsx
and layout.tsx
don't have anything wrond as far as I can tell.![Avatar](https://cdn.discordapp.com/embed/avatars/0.png)
Romanian Mioritic Shepherd DogOP
Yes, thank you so much for help! I did find something wrong in my middleware that was causing this.
![Avatar](https://cdn.discordapp.com/avatars/548149742207631360/2b1e750ac12613e7f54964225371f39b.webp?size=256)
not-milo.tsx
Glad to hear you fixed it ✌ðŸ»