next.js
c16a9b52 - Add the next/go SDK and move Go Proxy helpers into it (#101874)

Commit
4 hours ago
Add the next/go SDK and move Go Proxy helpers into it (#101874) ### What? Add the Go Proxy SDK as `next/go/proxy`: ```go import "next/go/proxy" proxy.Next(w) proxy.Rewrite(w, "/new-path") proxy.Next(w, proxy.WithRequestHeaders(headers)) ``` ### Why? Go tooling cannot resolve helpers generated into the proxy package. A concern-specific package works in editors and avoids `next.Next`. Functional options keep per-request options separate from static proxy configuration. ### How? - Ship one `next/go` module in the installed `next` package, with no root Go package. Helpers live under `proxy`. - Replace `ProxyOptions`/`RequestOptions` with `proxy.Option` and `proxy.WithRequestHeaders`. A nil header map preserves headers, an empty map removes them, and the last header option wins. - Manage the requirement and directory replacement for SDK imports, including pnpm and workspace layouts; recheck changed native endpoint results in development. - Inspect handler files using the native compiler's named-file selection, including build-tagged and platform-suffixed siblings. Include real routes under Go-ignored directories without editing unused fixture modules; ordinary dependencies retain package-mode selection. - Run SDK probing in an isolated offline Go environment. Private/VCS settings and user Go configuration cannot enable fetching or disable module mode; explicit cache locations, including XDG_CACHE_HOME, remain supported. - Permit ancestor module replacements within the source boundary, retaining self/outside-boundary rejection and symlink validation. - Keep Go input validation, the bounded ETXTBSY retry, and literal-# request-target rejection. ### Verification - SDK `go test -race ./...` and `go vet ./...` passed with Go 1.24.4. - All 37 SDK setup tests and 19 native-runtime tests passed using an isolated Jest/SWC source runner. - Reproduced the tagged/platform-source, testdata, and module-environment failures against the prior implementation. The private-dependency regression reaches local fake Git on the old code and never invokes it with the fix; no remote fetch is performed. - The real Rust live test `directory_replacements_outside_the_module_resolve_within_the_boundary` passed, including ancestor-source invalidation and outside-boundary rejection. The broader Rust suite was not run. - Independent review caught and verified the corrected XDG cache compatibility case. - Not run locally: full Next.js builds/typechecking and native e2e suites; framework dependencies/build outputs are not bootstrapped. CI remains the integration gate. --------- Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com> Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
Author
Parents
Loading