Skip to content

Commit

Permalink
Only add the draft header on live preview requests. Closes #1376
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Feb 17, 2020
1 parent 6e209b3 commit 3119fbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Http/Responses/DataResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ protected function handleDraft()
throw new NotFoundHttpException;
}

$this->headers['X-Statamic-Draft'] = true;
if ($this->isLivePreview()) {
$this->headers['X-Statamic-Draft'] = true;
}

return $this;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/FrontendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function page_is_displayed()
]
]);

$response = $this->get('/about')->assertStatus(200);
$response = $this->get('/about')
->assertStatus(200)
->assertHeaderMissing('X-Statamic-Draft');

$this->assertEquals('<h1>The About Page</h1> <p>This is the about page.</p>', trim($response->content()));
}
Expand Down

0 comments on commit 3119fbd

Please sign in to comment.