This commit is contained in:
Kismet Hasanaj
2026-05-02 20:07:02 +02:00
parent ce8672e283
commit 34dc9aec52
9428 changed files with 1733330 additions and 0 deletions
@@ -0,0 +1,31 @@
import type { IncomingHttpHeaders } from 'node:http';
import type { NextConfig } from '../../../server/config-shared';
import { NextResponse } from '../../../server/web/exports';
/**
* Tests the logic of `headers`, `redirects`, and `rewrites` in `next.config.js`.
* Given the provided next config, this function will return a `NextResponse`
* with the result of running the request through the custom routes.
*
* @example Test whether a given URL results in a redirect.
* ```
* import { unstable_getResponseFromNextConfig, getRedirectUrl } from 'next/server/testing'
* const response = await unstable_getResponseFromNextConfig({
* url: 'https://nextjs.org/test',
* nextConfig: {
* async redirects() {
* return [
* { source: '/test', destination: '/test2', permanent: false },
* ]
* },
* }
* });
* expect(response.status).toEqual(307);
* expect(getRedirectUrl(response)).toEqual('https://nextjs.org/test2');
* ```
*/
export declare function unstable_getResponseFromNextConfig({ url, nextConfig, headers, cookies, }: {
url: string;
nextConfig: NextConfig;
headers?: IncomingHttpHeaders;
cookies?: Record<string, string>;
}): Promise<NextResponse>;