Add a locked-down image upload endpoint for the admin panel
Posts, projects and about-me all carry an image column that could only ever be filled by typing a URL by hand, so every featured image in the database is still a placeholder. Uploads are the missing half of content management. Filenames are generated rather than reused from the client, which is what keeps a double extension or a path traversal out of a web-served directory. The upload surface is restricted to raster formats (no SVG, which can carry script) with a size and dimension ceiling, and throttled at 12/min against the general admin API's 30/min because an upload costs far more than a JSON write. Routes move to per-feature files registered from bootstrap/app.php, since api.php had become a chokepoint for parallel work on this repo.
This commit is contained in:
1 parent
6f6640330a
commit
6b03c0fbc3
6 files changed
+351
No files matched your search
@@ -5,6 +5,7 @@ use App\Http\Middleware\EnsureUserIsAdmin;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
@@ -12,6 +13,15 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
// Content-management endpoints live in their own files so the public and
|
||||
// legacy routes in api.php stay readable. `then:` does not inherit the
|
||||
// `api:` prefix or middleware group from the arguments above, so both
|
||||
// are applied explicitly here to keep these routes identical in shape
|
||||
// to the ones declared in routes/api.php.
|
||||
then: function () {
|
||||
Route::prefix('api')->middleware('api')->group(base_path('routes/media.php'));
|
||||
Route::prefix('api')->middleware('api')->group(base_path('routes/crud.php'));
|
||||
},
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
// Let the Next.js admin panel authenticate with a Sanctum session
|
||||
|
||||
Reference in new issue
Block a user