Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass 404 errors to the browser instead of ignoring it #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Nutsweb/LaravelPrerender/PrerenderMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ private function getPrerenderedPageResponse(SymfonyRequest $request)
// Return the Guzzle Response
return $this->client->get('/' . urlencode($request->getUri()), compact('headers'));
} catch (RequestException $exception) {
// Pass 404 errors to the browser assuming it comes from meta-tag prerender-status-code
if ($exception->getCode() == '404') {
\App::abort('404');
}

// In case of an exception, we only throw the exception if we are in debug mode. Otherwise,
// we return null and the handle() method will just pass the request to the next middleware
// and we do not show a prerendered page.
Expand Down