Skip to content

Commit ea0469e

Browse files
committed
PWA: Prevent passing credentials to avoid redirection issues
For #4649 More of a patch around the issue for now. Have opened #4656 to properly address.
1 parent 889b0da commit ea0469e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

app/App/PwaManifestBuilder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ class PwaManifestBuilder
66
{
77
public function build(): array
88
{
9+
// Note, while we attempt to use the user's preference here, the request to the manifest
10+
// does not start a session, so we won't have current user context.
11+
// This was attempted but removed since manifest calls could affect user session
12+
// history tracking and back redirection.
13+
// Context: https://github.com/BookStackApp/BookStack/issues/4649
914
$darkMode = (bool) setting()->getForCurrentUser('dark-mode-enabled');
1015
$appName = setting('app-name');
1116

resources/views/layouts/base.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class="{{ setting()->getForCurrentUser('dark-mode-enabled') ? 'dark-mode ' : ''
2929
<link rel="icon" type="image/png" sizes="32x32" href="{{ setting('app-icon-32') ?: url('/icon-32.png') }}">
3030

3131
<!-- PWA -->
32-
<link rel="manifest" href="{{ url('/manifest.json') }}" crossorigin="use-credentials">
32+
<link rel="manifest" href="{{ url('/manifest.json') }}">
3333
<meta name="mobile-web-app-capable" content="yes">
3434

3535
@yield('head')

tests/PwaManifestTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ public function test_pwa_meta_tags_in_head()
2424
{
2525
$html = $this->asViewer()->withHtml($this->get('/'));
2626

27-
// crossorigin attribute is required to send cookies with the manifest,
28-
// so it can react correctly to user preferences (dark/light mode).
29-
$html->assertElementExists('head link[rel="manifest"][href$="manifest.json"][crossorigin="use-credentials"]');
27+
$html->assertElementExists('head link[rel="manifest"][href$="manifest.json"]');
3028
$html->assertElementExists('head meta[name="mobile-web-app-capable"][content="yes"]');
3129
}
3230

0 commit comments

Comments
 (0)