Issue #537💬 AnsweredOpened November 17, 2017by michaellwatson1 reactions

Adding a request header on beforeSend

Quick answerby michaellwatson1

Instead of beforeSend, use the headers like this headers:{'X-CSRF-TOKEN':'foo'},

Read full answer below ↓

Question

Im using storageManager remote but the site has csrf token

beforeSend: function (t) {
    var token = $('meta[name="csrf_token"]').attr('content');
                    if (token) {
                        return t.setRequestHeader('X-CSRF-TOKEN', token);
                    }
     },

Gives an error "Uncaught TypeError: Cannot read property 'setRequestHeader' of undefined" obviously because t is undefined, how can I pass the headers into beforeSend without changing grapesjs

Answers (2)

michaellwatsonNovember 17, 2017

Instead of beforeSend, use the headers like this

headers:{'X-CSRF-TOKEN':'foo'},

lock[bot]September 18, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.