mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 16:14:42 +00:00
refactor(v5): extract csrfToken into shared lib/csrf.js module
This commit is contained in:
1 parent
c178dfdb39
commit
6b8f50a90e
3 files changed
+8
-4
No files matched your search
@@ -1,10 +1,7 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
|
||||
function csrfToken() {
|
||||
return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') ?? '';
|
||||
}
|
||||
import { csrfToken } from '@/lib/csrf';
|
||||
|
||||
function persistSelection(projectUuid, environmentUuid) {
|
||||
void fetch('/v5/selection', {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export function csrfToken() {
|
||||
return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') ?? '';
|
||||
}
|
||||
@@ -327,6 +327,8 @@ it('defines the v5 home page as a shadcn styled canvas shell', function () {
|
||||
expect($homePage)
|
||||
->toContain('Magic')
|
||||
->toContain("import { AppNavbar } from '@/components/app-navbar';")
|
||||
->not->toContain("import { csrfToken } from '@/lib/csrf';")
|
||||
->not->toContain('function csrfToken()')
|
||||
->toContain('<AppNavbar')
|
||||
->toContain('bg-background text-foreground')
|
||||
->toContain('h-dvh overflow-hidden bg-background text-foreground')
|
||||
@@ -340,6 +342,8 @@ it('defines the v5 home page as a shadcn styled canvas shell', function () {
|
||||
->not->toContain("'X-CSRF-TOKEN': csrfToken()");
|
||||
|
||||
expect($navbar)
|
||||
->toContain("import { csrfToken } from '@/lib/csrf';")
|
||||
->not->toContain('function csrfToken()')
|
||||
->toContain('export function AppNavbar')
|
||||
->toContain('/coolify-logo.svg')
|
||||
->toContain('className="fixed inset-x-0 top-0 z-40 border-b border-border bg-background"')
|
||||
|
||||
Reference in new issue
Block a user