Skip to content

Commit

Permalink
Updating cache control (#410)
Browse files Browse the repository at this point in the history
* adding cache control

* update
  • Loading branch information
edgarpavlovsky authored Dec 7, 2023
1 parent 6bf4975 commit ea68190
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/marginfi-v2-ui/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ export const config = {
export function middleware(req: NextRequest) {
const basicAuth = req.headers.get("authorization");
const url = req.nextUrl;
const response = NextResponse.next();
response.headers.set('Vercel-CDN-Cache-Control', 'private, max-age=10');
response.headers.set('CDN-Cache-Control', 'private, max-age=10');
response.headers.set('Cache-Control', 'private, max-age=10');

if (process.env.AUTHENTICATION_DISABLED === "true") {
return NextResponse.next();
return response;
}

if (basicAuth) {
Expand All @@ -20,7 +24,7 @@ export function middleware(req: NextRequest) {
const expectedPassword = process.env.AUTHENTICATION_PASSWORD || "admin";

if (providedUser === expectedUser && providedPassword === expectedPassword) {
return NextResponse.next();
return response;
}
}
url.pathname = "/api/auth";
Expand Down

1 comment on commit ea68190

@vercel
Copy link

@vercel vercel bot commented on ea68190 Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.