File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,4 +16,7 @@ VITE_THEME_OWNERSHIP_PER_PAGE=6
1616# plugin configurations
1717VITE_PLUGINS_PER_PAGE = 20
1818VITE_PLUGIN_FAVORITES_PER_PAGE = 6
19- VITE_PLUGIN_OWNERSHIP_PER_PAGE = 6
19+ VITE_PLUGIN_OWNERSHIP_PER_PAGE = 6
20+
21+ # CSRF token identifier
22+ VITE_CSRF_TOKEN_IDENTIFIER = " LOCAL-XSRF-TOKEN"
Original file line number Diff line number Diff line change @@ -68,10 +68,13 @@ const formatPreviewIdToTitleCase = (input: string): string => {
6868} ;
6969
7070/**
71- * Reads the CSRF token out of the XSRF-TOKEN cookie.
71+ * Reads the CSRF token out of the csrf token cookie.
7272 */
7373const getCsrfTokenFromCookie = ( ) : string | null => {
74- const match = document . cookie . match ( / (?: ^ | ; \s * ) X S R F - T O K E N = ( [ ^ ; ] + ) / ) ;
74+ const cookieName = import . meta. env . VITE_CSRF_TOKEN_IDENTIFIER || 'XSRF-TOKEN' ;
75+ const escaped = cookieName . replace ( / [ - [ \] { } ( ) * + ? . , \\ ^ $ | # \s ] / g, '\\$&' ) ;
76+ const pattern = new RegExp ( `(?:^|;\\s*)${ escaped } =([^;]+)` ) ;
77+ const match = document . cookie . match ( pattern ) ;
7578 return match ? decodeURIComponent ( match [ 1 ] ) : null ;
7679} ;
7780
You can’t perform that action at this time.
0 commit comments