Question: Let say Client1 has a big array in browser (javascript). Client2 has the same array.
Now when Client1 click Shuffle button, this array will sort by randomly. The problem is I want to sync this new order to Client2.  

The idea is I don't want to send all item over network to Client2 because it's big. Then I think about a function `array.shuffle(n)` where n is a random number. The shuffle function use n to sort array somehow. And when I send `n` to Client2, it call the same function and get the same order of array.  

Is there a function like that ?

Answer: 
Run your code in a beforeEach statement.

```
beforeEach(() => {
    cy.server({
        onAnyRequest: function(route, proxy) {
           proxy.xhr.setRequestHeader('X-CSRFToken', cy.getCookie('csrftoken'));
       }
    })
});

```
I think you're looking for `onRequest` instead of `onAnyRequest`. [Here's the documentation for `cy.server` options](https://docs.cypress.io/api/commands/server.html#Arguments)