Skip to content

Commit

Permalink
Remove csrf_cookie_name
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Sep 9, 2021
1 parent a56eafe commit 249e6e6
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
7 changes: 1 addition & 6 deletions config/scribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,14 @@
'base_url' => null,

/**
* Fetch a CSRF token before each request. Needed if you're using Laravel Sanctum.
* Fetch a CSRF token before each request, and add it as an X-XSRF-TOKEN header. Needed if you're using Laravel Sanctum.
*/
'use_csrf' => false,

/**
* The URL to fetch the CSRF token from (if `use_csrf` is true).
*/
'csrf_url' => '/sanctum/csrf-token',

/**
* The name of the cookie to fetch the CSRF token from after hitting the `csrf_url`.
*/
'csrf_cookie_name' => 'XSRF-TOKEN',
],

/*
Expand Down
2 changes: 1 addition & 1 deletion resources/js/tryitout.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async function executeTryOut(endpointId, form) {
let preflightPromise = Promise.resolve();
if (window.useCsrf && window.csrfUrl) {
preflightPromise = makeAPICall('GET', window.csrfUrl, {}, {}, {}, null).then(() => {
headers['X-XSRF-TOKEN'] = getCookie(window.csrfCookieName);
headers['X-XSRF-TOKEN'] = getCookie('XSRF-TOKEN');
});
}

Expand Down
1 change: 0 additions & 1 deletion resources/views/themes/default/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
var baseUrl = "{{ $tryItOut['base_url'] ?? config('app.url') }}";
var useCsrf = Boolean({{ $tryItOut['use_csrf'] ?? null }});
var csrfUrl = "{{ $tryItOut['csrf_url'] ?? null }}";
var csrfCookieName = "{{ $tryItOut['csrf_cookie_name'] ?? "XSRF-TOKEN" }}";
</script>
<script src="{{ u::getVersionedAsset($assetPathPrefix.'js/tryitout.js') }}"></script>
@endif
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected function upgradeConfigFileIfNeeded(): void
$changes = $upgrader->dryRun();
if (!empty($changes)) {
$this->newLine();
sleep(0.4);

$this->warn("You're using an updated version of Scribe, which added new items to the config file.");
$this->info("Here are the changes:");
foreach ($changes as $change) {
Expand Down

0 comments on commit 249e6e6

Please sign in to comment.