Export fails when image file URLs are used in <a href> #141
Replies: 2 comments
-
|
Another workaround where you won't need to adjust each link: |
Beta Was this translation helpful? Give feedback.
-
|
This isn't really a bug in the package. The crawler discovers all internal The static files from your The easiest fix is the workaround @rambii suggested: add a catch-all route that serves the static files: Route::get('images/{file}', function ($file) {
$path = public_path("images/{$file}");
if (file_exists($path)) {
return response()->file($path);
}
abort(404);
})->where('file', '.*');Alternatively, you can disable crawling and specify the paths to export manually: // config/export.php
'crawl' => false,
'paths' => ['/', '/about', '/gallery'], |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
When using Spatie’s export/crawler on a Blade template, if gallery images are wrapped in
<a href="{{ asset(...) }}">, the crawler attempts to fetch each URL over HTTP. If the live server cannot serve the file (e.g., filenames contain spaces, parentheses, or the file is missing), it returns a 500 error, causing the export to fail.Example of problematic code:
Expected behavior
During local export, the crawler should:
<a href>instead of HTTP URLs.Observed behavior
RuntimeException, e.g.:URL [https://example.com/images/projects/filename.jpg] found on [...] returned status code [500]Proposed solution / workaround
$image->getPathname()for<a href>during local exports:Additional context
<img src>points to the local filesystem.<a href>points to a URL the crawler tries to fetch.Steps to reproduce
<a href="{{ asset(...) }}">.Beta Was this translation helpful? Give feedback.
All reactions