Skip to content

Commit

Permalink
fix(Middleware): removed cors stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
andy1uu committed May 6, 2024
1 parent cb2672b commit 4e1c516
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 17 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 0 additions & 3 deletions src/app/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ export default axios.create({
headers: {
"Content-Type": "application/json",
"API-Key": process.env.API_KEY,
"origin":process.env.NODE_ENV === "production"
? "https://andyluu.vercel.app"
: "http://localhost:3000"
},
});
14 changes: 0 additions & 14 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
import { NextRequest, NextResponse } from "next/server";

const allowedOrigins =
process.env.NODE_ENV === "production"
? ["https://andyluu.vercel.app"]
: ["http://localhost:3000"];

export const middleware = (request: NextRequest) => {
const origin = request.headers.get("origin");

if (origin && !allowedOrigins.includes(origin) || !origin) {
return new NextResponse(null, {
status: 400,
statusText: "Bad Request",
headers: { "Content-Type": "text/plain" },
});
}

const apiKey = request.headers.get("API-Key");

Expand Down

0 comments on commit 4e1c516

Please sign in to comment.