PageSourceSearch

https://www.cospa.com/js/csrf_token.js

js cospa.com collected 2026-10-09 22:41:02 UTC 1,164 bytes, 44 lines download raw bytes

1//リクエストヘッダーにCSRFトークンの情報を追記する
2$(document).ready(function(){
3    $.ajaxSetup({
4        beforeSend:function(xhr){
5            xhr.setRequestHeader(
6                'X-CSRF-Token',
7                window.CSRF_TOKEN
8            );
9        }
10    });
11});
12
13//ReactのfetchにCSRFトークンを追記する
14(function(){
15
16    //fetch未対応の場合は何も実行せずにリターン
17    if(!window.fetch){
18        return;
19    }
20
21    //元のfetchを格納
22    const originalFetch = window.fetch;
23
24    window.fetch = function (url, options){
25        options = options || {};
26        const method = (options.method || 'GET').toUpperCase();
27
28        //メソッドを判別
29        if(['POST','PUT','PATCH','DELETE'].indexOf(method) !== -1){
30            //CSRFトークンを追記
31            options.headers = {
32                ...(options.headers || {}),
33                'X-CSRF-Token': window.CSRF_TOKEN
34            };
35        }
36
37        //元のfetchを呼び出す
38        return originalFetch.call(
39            this,
40            url,
41            options
42        );
43    };
44})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.