Relative Content

Tag Archive for next.js

Why does Next.js middleware only execute on the first redirect and not subsequently?

I am using middleware in Next.js to check user authentication and redirect to the login page if the token is missing. The middleware executes correctly on the first visit to any page, but if I navigate to a page that triggers a redirect, the middleware does not execute again for subsequent redirects to the same page. It only executes again after some time has passed, and then the cycle repeats.
Here is my middleware code:

problem with next js after switching to middleware

i am using next js 14 app router. i am doing the admin panel now.
so for authentication, i decided to use middleware. but as soon as i started to use middleware i got a problem [TypeError: Failed to parse URL from /api/v0/…] .
i am using fetch method for making requests to my api (which is running on docker container on localhost:8000).

“Cannot find name” while using typescript in Next Js

These errors are shown
What should I do to resolve this problem.
I have also gone through so many other posts and made some changes, reloaded the window but none of them helped.
something like “initialising JS/TS feature” runs as I open the layout.tsx and after this the error starts coming.
Also it doesn’t affect the web page it is getting rendered and working perfectly.
Also this error is coming only in layout.tsx.

Error: Body exceeded 1 MB limit. in Next js

when i’m sending a array with over 1mb file size to Nextjs server then I’m getting Error: Body exceeded 1 MB limit. error , i have already tried to resolve this by adding file size configuration in next.config.js and also but that was not worked and after i was added file size config. in same of the server file but still not resolve

Error: Body exceeded 1 MB limit. in Next js

when i’m sending a array with over 1mb file size to Nextjs server then I’m getting Error: Body exceeded 1 MB limit. error , i have already tried to resolve this by adding file size configuration in next.config.js and also but that was not worked and after i was added file size config. in same of the server file but still not resolve