Custom 404 page causing hard navigation
Unanswered
Labrador Retriever posted this in #help-forum
Labrador RetrieverOP
I get this error “Error: Invariant: attempted to hard navigate to the same URL /information localhost:3000/information” when using a custom 404 page
next.config
404bug.js
middleware.js
In v14.1.4 it worked fine
https://github.com/vercel/next.js/compare/v14.1.4...v14.2.6
next.config
rewrites() {
return {
fallback: [
{
source: "/:path*",
destination: "/404bug?path=:path*",
locale: false,
},
],
};
},404bug.js
const BugFixer = () => null;
export default BugFixer;
export const getServerSideProps = () => ({ notFound: true });middleware.js
import { NextResponse } from "next/server";
export async function middleware(req) {
// some code
return NextResponse.next();
}In v14.1.4 it worked fine
https://github.com/vercel/next.js/compare/v14.1.4...v14.2.6
1 Reply
@Labrador Retriever I get this error “Error: Invariant: attempted to hard navigate to the same URL /information localhost:3000/information” when using a custom 404 page
**next.config**
js
rewrites() {
return {
fallback: [
{
source: "/:path*",
destination: "/404bug?path=:path*",
locale: false,
},
],
};
},
**404bug.js**
js
const BugFixer = () => null;
export default BugFixer;
export const getServerSideProps = () => ({ notFound: true });
**middleware.js**
js
import { NextResponse } from "next/server";
export async function middleware(req) {
// some code
return NextResponse.next();
}
In v14.1.4 it worked fine
https://github.com/vercel/next.js/compare/v14.1.4...v14.2.6
please do not repost the question. i'll delete the duplicate you just posted which is the third time at least that you have posted this question.
you may bump the question (at most once a day) to get it more attention.
you may bump the question (at most once a day) to get it more attention.