cloudflare/vinext

Public

mirrored from https://github.com/cloudflare/vinextAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.0.9

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/fixtures/app-basic/next.config.ts

97lines · modecode

1/**
2 * Next.js config for the app-basic test fixture.
3 *
4 * This config serves both Vitest integration tests (app-router.test.ts)
5 * and Playwright E2E tests (ON-12, ON-13, ON-15).
6 *
7 * IMPORTANT: The Vitest test previously wrote a temporary next.config.mjs.
8 * Since next.config.ts takes priority over .mjs, this file must include
9 * all redirects/rewrites/headers that those tests expect.
10 */
11import type { NextConfig } from "next";
12
13const nextConfig: NextConfig = {
14 // Default is false — trailing slashes are stripped (redirects /about/ → /about)
15 // trailingSlash: false,
16
17 async redirects() {
18 return [
19 // Used by Vitest: app-router.test.ts
20 {
21 source: "/old-about",
22 destination: "/about",
23 permanent: true,
24 },
25 // Used by Vitest: app-router.test.ts (permanent: false → 307)
26 {
27 source: "/old-blog/:slug",
28 destination: "/blog/:slug",
29 permanent: false,
30 },
31 // Used by E2E: config-redirect.spec.ts (permanent → 308)
32 {
33 source: "/config-redirect-source",
34 destination: "/about",
35 permanent: true,
36 },
37 // Used by E2E: config-redirect.spec.ts (non-permanent → 307)
38 {
39 source: "/config-redirect-query",
40 destination: "/about?from=config",
41 permanent: false,
42 },
43 // Used by E2E: config-redirect.spec.ts — has cookie condition
44 {
45 source: "/has-cookie-redirect",
46 destination: "/about",
47 permanent: false,
48 has: [{ type: "cookie", key: "redirect-me" }],
49 },
50 // Used by E2E: config-redirect.spec.ts — missing cookie condition
51 {
52 source: "/missing-cookie-redirect",
53 destination: "/about",
54 permanent: false,
55 missing: [{ type: "cookie", key: "stay-here" }],
56 },
57 ];
58 },
59
60 async rewrites() {
61 return {
62 beforeFiles: [
63 // Used by Vitest: app-router.test.ts
64 { source: "/rewrite-about", destination: "/about" },
65 ],
66 afterFiles: [
67 // Used by Vitest: app-router.test.ts
68 { source: "/after-rewrite-about", destination: "/about" },
69 // Used by E2E: config-redirect.spec.ts
70 { source: "/config-rewrite", destination: "/" },
71 ],
72 fallback: [],
73 };
74 },
75
76 async headers() {
77 return [
78 // Used by Vitest: app-router.test.ts
79 {
80 source: "/api/(.*)",
81 headers: [{ key: "X-Custom-Header", value: "vinext-app" }],
82 },
83 // Used by Vitest: app-router.test.ts
84 {
85 source: "/about",
86 headers: [{ key: "X-Page-Header", value: "about-page" }],
87 },
88 // Used by E2E: config-redirect.spec.ts (catch-all for e2e header test)
89 {
90 source: "/(.*)",
91 headers: [{ key: "X-E2E-Header", value: "vinext-e2e" }],
92 },
93 ];
94 },
95};
96
97export default nextConfig;
98