diff --git a/crates/next-dev-tests/tests/integration/next/router/headers/input/next.config.js b/crates/next-dev-tests/tests/integration/next/router/headers/input/next.config.js new file mode 100644 index 00000000000000..002c1d0913776f --- /dev/null +++ b/crates/next-dev-tests/tests/integration/next/router/headers/input/next.config.js @@ -0,0 +1,16 @@ +/** @type {import('next').NextConfig} */ +module.exports = { + async headers() { + return [ + { + source: "/foo", + headers: [ + { + key: "x-foo", + value: "bar", + }, + ], + }, + ]; + }, +}; diff --git a/crates/next-dev-tests/tests/integration/next/router/headers/input/pages/foo.js b/crates/next-dev-tests/tests/integration/next/router/headers/input/pages/foo.js new file mode 100644 index 00000000000000..b9efca873d59ed --- /dev/null +++ b/crates/next-dev-tests/tests/integration/next/router/headers/input/pages/foo.js @@ -0,0 +1,3 @@ +export default function Foo() { + return "check x-foo header"; +} diff --git a/crates/next-dev-tests/tests/integration/next/router/headers/input/pages/index.js b/crates/next-dev-tests/tests/integration/next/router/headers/input/pages/index.js new file mode 100644 index 00000000000000..2cc1ed64a50d27 --- /dev/null +++ b/crates/next-dev-tests/tests/integration/next/router/headers/input/pages/index.js @@ -0,0 +1,17 @@ +import { useEffect } from "react"; + +export default function Foo() { + useEffect(() => { + // Only run on client + import("@turbo/pack-test-harness").then(runTests); + }); + + return "index"; +} + +function runTests() { + it("should set header onto response", async () => { + const res = await fetch("/foo"); + expect(res.headers.get("x-foo")).toBe("bar"); + }); +}