next.js
5557bdda - [Segment Cache] Support third-party redirects in output: "export" mode (#81247)

Commit
175 days ago
[Segment Cache] Support third-party redirects in output: "export" mode (#81247) In output: "export" mode, we can't use headers to request a particular segment. Instead, we encode the extra request information into the URL. This is not part of the "public" interface of the app; it's an internal Next.js implementation detail that the app developer should not need to concern themselves with. For example, to request a segment: - Path passed to <Link>: /path/to/page - Path passed to fetch: /path/to/page/__next-segments/_tree *(This is not the exact protocol, just an illustration.)* Before we do that, though, we need to account for redirects. Even in output: "export" mode, a proxy might redirect the page to a different location, but we shouldn't assume or expect that they also redirect all the segment files, too. To check whether the page is redirected, we perform a range request of the first N bytes of the HTML document, just enough to verify the document comes from the same build. The canonical URL is determined from the response. Then we can use the canonical URL to request the route tree. Note: We could embed the route tree into the HTML document, to avoid a second request. We're not doing that currently because it would make the HTML document larger and affect normal page loads.
Author
Parents
Loading