How to add an authentication header in sencha architect, using the store option?

71 Views Asked by At

I'm trying to add an authentication header to the sencha architect Store, the api that I'm consuming is an api with sanctum authentication. In the components I made a POST request placing the auth token and everything went well, my error is happening in the following part within the Store: There is a Headers option, and I imagine that would be where I put 'Authorizathion' and then the access token, for example: 'Authorizathion': Bearer 1|TokenTeste. However, in its composition, it understands the entire line as a string, and not an array that I'm passing parameters and values into, would anyone know how to pass this parameter correctly? Or would there be another viable option for such functionality? I am attaching a corresponding image of this, to exemplify how the Headers option is only as a string.

I tried adding an authentication token to the headers option in the sencha architect store. However, it does not open the array option with parameters and values, just a single string.enter image description here

1

There are 1 best solutions below

0
Sergey Bogdanov On

You can globally modify each ajax request header by adding this code fragment into you app.controller init function for example. I'dont have Sencha architect but I suppose you could create app controller in "Applications/Controllers" tree item.

Ext.Ajax.setWithCredentials(true);
Ext.Ajax.on({
    beforerequest: function(conn, options) {
        options.headers = options.headers || {};
        options.headers['Authorization'] = 'Bearer ASDFASDFQWERQ....WERh';
        // Dont forget to hide hash to variable
    },

});