Issue #537Opened November 17, 2017by michaellwatson1 reactions

Adding a request header on beforeSend

Question

Code SnippetTEXT
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, 20171 reactions

Instead of beforeSend, use the headers like this

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

lock[bot]September 18, 20190 reactions

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.