Skip to content

Commit ae8f51b

Browse files
committed
Create a configuration option for custom default request headers
1 parent 29864f5 commit ae8f51b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

config/request-docs.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
// \App\Http\Middleware\NotFoundWhenProduction::class,
1717
],
1818

19+
/*
20+
* Default headers shown on the request headers editor
21+
*/
22+
'default_request_headers' => [
23+
'Accept' => 'application/json',
24+
'X-CSRF-TOKEN' => '',
25+
'Authorization' => 'Bearer',
26+
],
27+
1928
/**
2029
* Path to to static HTML if using command line.
2130
*/

resources/views/index.blade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,7 @@ class="my-prism-editor"
660660
filterTerm: ''
661661
},
662662
created: function () {
663-
axios.defaults.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
664-
axios.defaults.headers.common['Authorization'] = 'Bearer '
665-
this.requestHeaders = JSON.stringify(axios.defaults.headers.common, null, 2)
663+
this.requestHeaders = JSON.stringify({!! json_encode(config('request-docs.default_request_headers')) !!}, null, 2)
666664
},
667665
methods: {
668666
highlightSidebar(idx) {

0 commit comments

Comments
 (0)