mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
1c69ce3fef
* fix(pages-router): load custom _app/_document via resolved file paths in dev The dev server imported pages/_app and pages/_document by extensionless id and relied on the module runner applying custom resolve.extensions (e.g. ".page.tsx" from pageExtensions). The runner no longer resolves those, so apps using pageExtensions silently lost their custom App/Document (the load failure is swallowed). Import the file path resolved by findFileWithExts instead, at all three call sites. * test(e2e): add pages-router-complex example app and behaviour suite A deliberately convoluted Pages Router app that serves as a compatibility target: the kinds of patterns that only surface in large, long-lived enterprise pages-router codebases, each pinned by a Playwright spec whose behaviour is verified against real Next.js (73/73 under next dev --webpack). Highlights: custom pageExtensions everywhere (middleware.page.ts, instrumentation.page.ts), app-shell getInitialProps with a TTL-memoised chrome fetch and embedded-shell/draft bypasses, class _document with its own GIP, a zone route dimension driven by middleware rewrites and a real i18next/react-i18next runtime, catch-all routes with static-sibling precedence and cacheable-404/redirect hygiene, record-driven template branching on a dynamic/static/dynamic route, an urql-style server-snapshot data layer, shallow routing + router.events + next/compat/router + next/navigation hooks in pages, next/image with a custom loader, draft-mode gateway APIs, a function-form next.config, and a Cloudflare setup matching the vinext init scaffold. The playwright project (pages-router-complex, port 4199) is intentionally not in the CI e2e matrix: vinext currently passes 59/73, and the failures are the compat backlog documented in the example README. * fix(pages-router): cover compound page extensions in CI
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
/**
|
|
* Environment-derived runtime settings, split into a full server-side view
|
|
* and a public subset that the app shell's getInitialProps serialises into
|
|
* props (and ProviderShell re-exposes through context).
|
|
*
|
|
* Secrets are resolved under a per-product credential scope (`ATLAS_...`) so
|
|
* shared modules can be pointed at different credentials per consuming
|
|
* product — the same pattern `credentialScope` follows throughout this app.
|
|
*/
|
|
|
|
export type DataEdgeSettings = {
|
|
url: string;
|
|
token: string;
|
|
};
|
|
|
|
export type PublicSettings = {
|
|
dataEdge: DataEdgeSettings;
|
|
tagsScriptUrl?: string;
|
|
trialsSnippetId?: string;
|
|
rumProbeUrl?: string;
|
|
engage?: {
|
|
appId?: string;
|
|
apiKey?: string;
|
|
};
|
|
};
|
|
|
|
export type ServerSettings = PublicSettings & {
|
|
relayUpstreamUrl: string;
|
|
purgeBearer?: string;
|
|
};
|
|
|
|
const env = (key: string): string | undefined => process.env[key];
|
|
|
|
export const scopedSecret = (
|
|
credentialScope: string,
|
|
name: string,
|
|
): string | undefined => env(`${credentialScope.toUpperCase()}_${name}`);
|
|
|
|
export const readServerSettings = (): ServerSettings => ({
|
|
dataEdge: {
|
|
url: env("ATLAS_DATA_EDGE_URL") ?? "/api/graph",
|
|
token: env("ATLAS_DATA_EDGE_TOKEN") ?? "dev-loopback-token",
|
|
},
|
|
tagsScriptUrl: env("ATLAS_TAGS_SCRIPT_URL"),
|
|
trialsSnippetId: env("ATLAS_TRIALS_SNIPPET_ID"),
|
|
rumProbeUrl: env("ATLAS_RUM_PROBE_URL"),
|
|
engage: {
|
|
appId: env("ATLAS_ENGAGE_APP_ID"),
|
|
apiKey: env("ATLAS_ENGAGE_API_KEY"),
|
|
},
|
|
relayUpstreamUrl: env("ATLAS_RELAY_UPSTREAM_URL") ?? "",
|
|
purgeBearer: env("ATLAS_PURGE_BEARER"),
|
|
});
|
|
|
|
export const readPublicSettings = (): PublicSettings => {
|
|
const { relayUpstreamUrl: _r, purgeBearer: _p, ...publicSettings } =
|
|
readServerSettings();
|
|
return publicSettings;
|
|
};
|
|
|
|
/**
|
|
* Public settings narrowed to what data-edge-backed pages need. Kept as a
|
|
* dedicated accessor because the architecture historically distinguished two
|
|
* data-layer flavours; the split survives as this call site used by the app
|
|
* shell's getInitialProps.
|
|
*/
|
|
export const readPublicSettingsForData = (): PublicSettings =>
|
|
readPublicSettings();
|