Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Tahsan's avatar

Getting 404 when loading dynamic routes on nextjs

I make a dynamic route like [results].js

import { useRouter } from 'next/router'

const Results = () => {
    const router = useRouter();
    const { results } = router.query;

    return <p>Post: {results}</p>
}

export default Results

and configure my next.confi.js

module.exports = {
    trailingSlash: true,
}

It's working well on dev mode but in production mode, I have the only problem with the dynamic page route after npm run export.When I brows htttps://my-domain/search/searchslog it's getting 404 error page.

0 likes
2 replies
chideraugo's avatar

@neilstee hi, i'm having this issue too and i also ran "next build && next export" can you please help me out

Please or to participate in this conversation.