Browse Source

Merge pull request #9621 from jonathanhefner/nextjs-use-config-for-http-header

[nextjs] Use config to set HTTP `Server` header
Mike Smith 5 months ago
parent
commit
21c41f95a6

+ 0 - 7
frameworks/TypeScript/nextjs/middleware.ts

@@ -1,7 +0,0 @@
-import { NextRequest, NextResponse } from "next/server"
-
-export function middleware(request: NextRequest) {
-  const response = NextResponse.next()
-  response.headers.set("Server", "Next.js")
-  return response
-}

+ 11 - 0
frameworks/TypeScript/nextjs/next.config.ts

@@ -2,6 +2,17 @@ import type { NextConfig } from "next";
 
 const nextConfig: NextConfig = {
   output: "standalone",
+
+  async headers() {
+    return [
+      {
+        source: "/(.*?)",
+        headers: [
+          { key: "Server", value: "Next.js" },
+        ],
+      },
+    ]
+  },
 };
 
 export default nextConfig;