feat(api): Implement API response Cache-Control

- Introduce `withCacheControl` utility function for API responses.
- Apply `private, no-store` to authentication and data modification (POST, PATCH, DELETE) routes.
- Apply `private, no-cache` to sensitive data retrieval (GET) routes.
- Enhance security by preventing caching of private user data.
- Ensure fresh data is always fetched for authenticated API responses.
This commit is contained in:
Yusuf İpek
2026-02-07 16:51:46 +03:00
parent 669f6fa9d2
commit 6e8170d080
24 changed files with 179 additions and 70 deletions
+5
View File
@@ -126,6 +126,11 @@ export function successResponse<T>(
return NextResponse.json(body, { status });
}
export function withCacheControl<T>(response: NextResponse<T>, value: string): NextResponse<T> {
response.headers.set('Cache-Control', value);
return response;
}
/**
* Common error response helpers
*/