worker throws an error CSRF token injection

addEventListener('fetch', async (event) => { // Get the request object. const request = event.request; // Check if the request is a POST request. if (request.method === 'POST') { // Regenerate the CSRF token. const csrfToken = generateCsrfToken(); // Add the CSRF token to the request headers. request.headers.set('X-CSRF-Token', csrfToken); } // Fetch the response from the origin server. const response = await fetch(request); // Return the response. event.respondWith(response); }); function generateCsrfToken() { // Generate a random CSRF token. const csrfToken = Math.random().toString(36).substring(7); // Return the CSRF token. return csrfToken; } Above is the actual code.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server