B2B-88: add starter kit structure and elements
This commit is contained in:
17
packages/ui/src/makerkit/authenticity-token.tsx
Normal file
17
packages/ui/src/makerkit/authenticity-token.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
'use client';
|
||||
|
||||
export function AuthenticityToken() {
|
||||
const token = useCsrfToken();
|
||||
|
||||
return <input type="hidden" name="csrf_token" value={token} />;
|
||||
}
|
||||
|
||||
function useCsrfToken() {
|
||||
if (typeof window === 'undefined') return '';
|
||||
|
||||
return (
|
||||
document
|
||||
.querySelector('meta[name="csrf-token"]')
|
||||
?.getAttribute('content') ?? ''
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user