mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user