Comments (7)
Interesting... so the problem is not as phrased by the title, thought the problem exists.
One way to see the issue is with the devtools network, and preserve logs, but another is to modify the api endpoint to:
import { NextRequest, NextResponse } from 'next/server';
export const GET = (req: NextRequest) => {
console.log('redirect called', req.nextUrl.searchParams.get('_rsc'));
return NextResponse.json({ hello: 'there' });
};
And now you see, where this is going. When you have the loading
file, Next.js serves that suspense boundary to the client, so Loading
is seen by the client.
Then the framework is making a request for _rsc data to the endpoint, not that this endpoint serves 200 + json, an at the same time the framework is making a request to the endpoint, without the _rsc query.
I'd seem that this PR, #63786, referenced in #57257 should indeed take care of this 🤔
from next.js.
ah nice, what would be a more appropriate title?
from next.js.
I think the issue is still, a Double redirect when using a loading boundary and Route Handlers
From the test I see that, the intention had been to redirect to another page, not a Route Handler.
Though I am not sure I have the time to investigate a whole lot, but the issue is interesting to say the least.
from next.js.
Thanks hopefully a more appropriate title will help attract some more interest, it is slightly different as this issue is present if you redirect to another Page and a route handler. My example was a route handler as that is a cut down version of our use case (We need to do some cookie clean up and that was the only way we could think in the flow we have).
There is a work around that if the redirect is down in a child client component then you do not get the double render. However this is a bit messy and is not ideal
from next.js.
Alright, I see, the odd thing is that the test introduced by #63786 should really be guarding against that... I'll try to run the tests on this machine, to see what's up
from next.js.
Ok, I got them tests running here, and isolated to the test introduced in #63786 plus a router handler test redirect I wrote, and I can see that, the test is making sure the UI doesn't change, because the redirected to page (or my route handler), render with Date.now, so the assumption is made, should you show two different dates to the client, then you definitely did a double redirect, but that's not the entire picture.
I can see that the server makes a request with _rsc
, and one without it, where it'd seem that the UI ignores one, and uses the other, and that makes the test assumption pass.
I'll see if I can change the check to make the test fail.
from next.js.
We're experiencing the very same issue, which seems to have been introduced in 14.2.2
or 14.2.3
.
We temporarily downgraded to 14.2.1
, which doesn't show this weird behavior. For our use case it is critical, as the redirect involves a third party data generation API which doesn't allow the same url (incl. query params) to be called twice.
from next.js.
Related Issues (20)
- create-next-app v15 rc with --empty and src directory results in a broken tailwind.config.ts HOT 1
- vercel/styled-jsx error `DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.` HOT 1
- Build Error: Parsing css source code failed HOT 5
- Route Handlers Crash with bcrypt (see: #46493) HOT 5
- Forms example does not work with useActionState
- Failed to reload dynamic routes: Error: Catch-all must be the last part of the URL.
- static-export get searchParams is empty HOT 1
- static-export get searchParams is empty
- generateMetadata example not working HOT 1
- Use of deprecated dependency that leaks memory in `eslint-config-next` (inflight 1.0.6)
- 'next/dynamic' - SSR does not seem to work for dynamically imported components. HOT 1
- Duplicate Requests in Next.js 14 on Server Side with Parallel Routes and Intercepting Routes
- `router.replace()` on pages with query params cause entire page re-render on Next 14.2.3 HOT 1
- Form state not updating and suspended components reloading on first server action submission when using revalidatePath with loading.tsx in app router HOT 1
- `router.replace()` on pages with query params cause entire page re-render on Next 14.2.3 HOT 1
- Suspense boundary broken (ignored) after second server action call HOT 8
- Nonce exposed to the DOM
- [Bug][Next.js13]: renderError does not follow the err info of __NEXT_DATA__ when hytrate in client
- Docs: Wrong link for UseFormState. HOT 1
- `no-store` cache in nextjs config doesn't disable disk caching.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.