Skip to content

Commit

Permalink
Create middleware.js
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Jan 27, 2025
1 parent 49036a9 commit f8c8d35
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NextResponse } from "next/server";

export function middleware(req) {
const host = req.headers.get("host");
const allowedHosts = ["localhost:3000"];

if (!host || !allowedHosts.includes(host)) {
return new NextResponse("Invalid Host header", { status: 400 });
}

return NextResponse.next();
}

export const config = {
matcher: "/api/:path*",
};

0 comments on commit f8c8d35

Please sign in to comment.