mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 18:52:08 +01:00
feat: implement comprehensive CSRF protection
This commit is contained in:
19
app/api/csrf-token/route.ts
Normal file
19
app/api/csrf-token/route.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* CSRF Token API Endpoint
|
||||
*
|
||||
* This endpoint provides CSRF tokens to clients for secure form submissions.
|
||||
* It generates a new token and sets it as an HTTP-only cookie.
|
||||
*/
|
||||
|
||||
import { NextRequest } from "next/server";
|
||||
import { generateCSRFTokenResponse } from "../../../middleware/csrfProtection";
|
||||
|
||||
/**
|
||||
* GET /api/csrf-token
|
||||
*
|
||||
* Generates and returns a new CSRF token.
|
||||
* The token is also set as an HTTP-only cookie for automatic inclusion in requests.
|
||||
*/
|
||||
export function GET(request: NextRequest) {
|
||||
return generateCSRFTokenResponse();
|
||||
}
|
||||
Reference in New Issue
Block a user